Skip to content

Commit

Permalink
Fix: prefer-destructuring false positive on "super" (fixes #9625) (#9626
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Kei-Ito authored and not-an-aardvark committed Nov 19, 2017
1 parent 0cf081e commit a015234
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/prefer-destructuring.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module.exports = {
* @returns {void}
*/
function performCheck(leftNode, rightNode, reportNode) {
if (rightNode.type !== "MemberExpression") {
if (rightNode.type !== "MemberExpression" || rightNode.object.type === "Super") {
return;
}

Expand Down
10 changes: 9 additions & 1 deletion tests/lib/rules/prefer-destructuring.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ ruleTester.run("prefer-destructuring", rule, {
{
code: "var foo = object.foo;",
options: [{ VariableDeclarator: { object: false }, AssignmentExpression: { object: true } }]
}
},
"class Foo extends Bar { static foo() {var foo = super.foo} }"
],

invalid: [
Expand Down Expand Up @@ -276,6 +277,13 @@ ruleTester.run("prefer-destructuring", rule, {
message: "Use object destructuring.",
type: "AssignmentExpression"
}]
},
{
code: "class Foo extends Bar { static foo() {var bar = super.foo.bar} }",
errors: [{
message: "Use object destructuring.",
type: "VariableDeclarator"
}]
}
]
});

0 comments on commit a015234

Please sign in to comment.