Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Handle empty string property names in getFunctionNameWithKind #12104

Merged
merged 1 commit into from Aug 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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