Skip to content
Permalink
Browse files

Fix: Handle empty string property names in getFunctionNameWithKind (#…

  • Loading branch information
mdjermanovic authored and kaicataldo committed Aug 18, 2019
1 parent 9a043ff commit 3e5ceca4d2284b55a2292a1d3de9aa4cdf6fa213
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/rules/utils/ast-utils.js
  2. +4 −0 tests/lib/rules/require-await.js
  3. +2 −0 tests/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}'`);
}
}
@@ -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."]
@@ -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'",

0 comments on commit 3e5ceca

Please sign in to comment.
You can’t perform that action at this time.