Skip to content

Commit

Permalink
Fix: dot-notation false positive with private identifier (refs #14857)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Aug 6, 2021
1 parent 537cf6a commit 01b302d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rules/dot-notation.js
Expand Up @@ -141,6 +141,7 @@ module.exports = {
if (
!allowKeywords &&
!node.computed &&
node.property.type === "Identifier" &&
keywords.indexOf(String(node.property.name)) !== -1
) {
context.report({
Expand Down
7 changes: 6 additions & 1 deletion tests/lib/rules/dot-notation.js
Expand Up @@ -59,7 +59,12 @@ ruleTester.run("dot-notation", rule, {
"a[void 0];",
"a[b()];",
{ code: "a[/(?<zero>0)/];", parserOptions: { ecmaVersion: 2018 } },
{ code: "class C { foo() { this['#a'] } }", parserOptions: { ecmaVersion: 2022 } }
{ code: "class C { foo() { this['#a'] } }", parserOptions: { ecmaVersion: 2022 } },
{
code: "class C { #in; foo() { this.#in; } }",
options: [{ allowKeywords: false }],
parserOptions: { ecmaVersion: 2022 }
}
],
invalid: [
{
Expand Down

0 comments on commit 01b302d

Please sign in to comment.