Skip to content

Commit

Permalink
Fix: Handle empty string property names in getFunctionNameWithKind (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic authored and kaicataldo committed Aug 18, 2019
1 parent 9a043ff commit 3e5ceca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/utils/ast-utils.js
Expand Up @@ -1101,7 +1101,7 @@ module.exports = {
} else {
const name = module.exports.getStaticPropertyName(parent);

if (name) {
if (name !== null) {
tokens.push(`'${name}'`);
}
}
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/require-await.js
Expand Up @@ -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."]
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/utils/ast-utils.js
Expand Up @@ -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'",
Expand Down

0 comments on commit 3e5ceca

Please sign in to comment.