diff --git a/lib/rules/utils/ast-utils.js b/lib/rules/utils/ast-utils.js index 78ae7bc0157..ecf7db82ff3 100644 --- a/lib/rules/utils/ast-utils.js +++ b/lib/rules/utils/ast-utils.js @@ -1101,7 +1101,7 @@ module.exports = { } else { const name = module.exports.getStaticPropertyName(parent); - if (name) { + if (name !== null) { tokens.push(`'${name}'`); } } diff --git a/tests/lib/rules/require-await.js b/tests/lib/rules/require-await.js index c63a1ef5e86..7b43f326662 100644 --- a/tests/lib/rules/require-await.js +++ b/tests/lib/rules/require-await.js @@ -72,6 +72,10 @@ ruleTester.run("require-await", rule, { code: "(class { async foo() { doSomething() } })", errors: ["Async method 'foo' has no 'await' expression."] }, + { + code: "(class { async ''() { doSomething() } })", + errors: ["Async method '' has no 'await' expression."] + }, { code: "async function foo() { async () => { await doSomething() } }", errors: ["Async function 'foo' has no 'await' expression."] diff --git a/tests/lib/rules/utils/ast-utils.js b/tests/lib/rules/utils/ast-utils.js index 678b7f274df..02f57e11618 100644 --- a/tests/lib/rules/utils/ast-utils.js +++ b/tests/lib/rules/utils/ast-utils.js @@ -671,7 +671,9 @@ describe("ast-utils", () => { "async () => {}": "async arrow function", "({ foo: function foo() {} })": "method 'foo'", "({ foo: function() {} })": "method 'foo'", + "({ '': function() {} })": "method ''", "({ ['foo']: function() {} })": "method 'foo'", + "({ ['']: function() {} })": "method ''", "({ [foo]: function() {} })": "method", "({ foo() {} })": "method 'foo'", "({ foo: function* foo() {} })": "generator method 'foo'",