-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: prefer-destructuring says "Use destructuring" on "super" (#9625) #9626
Fix: prefer-destructuring says "Use destructuring" on "super" (#9625) #9626
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for contributing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a test case for a nested super call?
class Foo extends Bar { static get foo() {var bar = super.foo.bar } }
Asking because I'm not 100% sure that line 148 of the rule will catch that, since you'd have to check rightNode.object.object
in that case. In fact, you might need a recursive check, if I'm not mistaken about this. Even if does work, it'd be good to have a test so we can protect against a regression in that case.
I agree that it would be nice to have a test. Having said that, I think the implementation in this PR already handles that case correctly by reporting an error because Conceptually, the rule should report an error only when |
Thanks for the explanation. You are right that I had misunderstood conceptually how this rule is supposed to work and thought that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Thank you for the reviewing. I added another test to check what @platinumazure pointed out. class Foo extends Bar {
foo() {
var foo = super.foo;
}
} |
Thanks for contributing! |
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
This fixes #9625
What changes did you make? (Give an overview)
tests/lib/rules/prefer-destructuring.js
: I added a test to reproduce prefer-destructuring says "Use destructuring" on "super" #9625lib/rules/prefer-destructuring.js
: I updated a line to fix prefer-destructuring says "Use destructuring" on "super" #9625Is there anything you'd like reviewers to focus on?
No