Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix: camelcase false positive with computed property (fixes #13022) (#…
  • Loading branch information
mdjermanovic committed Mar 10, 2020
1 parent bc0c02c commit 0243549
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/camelcase.js
Expand Up @@ -186,7 +186,7 @@ module.exports = {

const assignmentKeyEqualsValue = node.parent.key.name === node.parent.value.name;

if (isUnderscored(name) && node.parent.computed) {
if (nameIsUnderscored && node.parent.computed) {
report(node);
}

Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/camelcase.js
Expand Up @@ -91,6 +91,14 @@ ruleTester.run("camelcase", rule, {
code: "obj.foo_bar = function(){};",
options: [{ properties: "never" }]
},
{
code: "const { ['foo']: _foo } = obj;",
parserOptions: { ecmaVersion: 6 }
},
{
code: "const { [_foo_]: foo } = obj;",
parserOptions: { ecmaVersion: 6 }
},
{
code: "var { category_id } = query;",
options: [{ ignoreDestructuring: true }],
Expand Down

0 comments on commit 0243549

Please sign in to comment.