Skip to content

Commit

Permalink
Fix: Don't check object destructing in integer property (fixes #8654) (
Browse files Browse the repository at this point in the history
  • Loading branch information
flowmemo authored and not-an-aardvark committed May 30, 2017
1 parent c4ac969 commit 9524833
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rules/prefer-destructuring.js
Expand Up @@ -109,8 +109,10 @@ module.exports = {
return;
}

if (checkArrays && isArrayIndexAccess(rightNode)) {
report(reportNode, "array");
if (isArrayIndexAccess(rightNode)) {
if (checkArrays) {
report(reportNode, "array");
}
return;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/prefer-destructuring.js
Expand Up @@ -72,6 +72,12 @@ ruleTester.run("prefer-destructuring", rule, {
{
code: "({ foo } = object);"
},
{

// Fix #8654
code: "var foo = array[0];",
options: [{ array: false }, { enforceForRenamedProperties: true }]
},
"[foo] = array;",
"foo += array[0]",
"foo += bar.foo"
Expand Down

0 comments on commit 9524833

Please sign in to comment.