Skip to content

Commit

Permalink
Fix: false negative of no-useless-rename (fixes #6502) (#6506)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea authored and gyandeeps committed Jun 28, 2016
1 parent 0a7936d commit 18663d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rules/no-useless-rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {

for (i = 0; i < properties.length; i++) {
if (properties[i].shorthand) {
return;
continue;
}

/**
Expand All @@ -94,7 +94,7 @@ module.exports = {
* so there is no "renaming" occurring here.
*/
if (properties[i].computed || !properties[i].key) {
return;
continue;
}

if (properties[i].key.type === "Identifier" && properties[i].key.name === properties[i].value.name ||
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/no-useless-rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ ruleTester.run("no-useless-rename", rule, {
parserOptions: { ecmaVersion: 6 },
errors: ["Destructuring assignment foo unnecessarily renamed."]
},
{
code: "let {a, foo: foo} = obj;",
output: "let {a, foo} = obj;",
parserOptions: { ecmaVersion: 6 },
errors: ["Destructuring assignment foo unnecessarily renamed."]
},
{
code: "let {foo: foo, bar: baz} = obj;",
output: "let {foo, bar: baz} = obj;",
Expand Down

0 comments on commit 18663d4

Please sign in to comment.