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
prefer-destructuring reports false positives with compound assignments #7881
prefer-destructuring reports false positives with compound assignments #7881
Comments
I can reproduce this, thanks for the report. It's happening because the rule is treating the line the same as let foo = bar.foo; ...which could be fixed to let {foo} = bar; |
This rule should only test variable definitions, not all types of assignments. global.window = jsdom().defaultView; |
@thealjey Actually, that looks like it's working as intended -- you can replace that line with ({ defaultView: global.window } = jsdom()); |
@not-an-aardvark Adding parentheses, seriously? Also, I don't think this rule should complain about things like this: const {param} = something.property; because:
|
There certainly might be room for improvement in the rule's design -- I was just clarifying that the rule is currently working as intended for your example. |
this rule is a very good idea, big 👍 to its author |
@thealjey Feel free to write up a proposal and submit a new issue if you see something you think could be improved. |
@kaicataldo And my suggestion is already out there, it's pretty simple. This rule should completely ignore everything but variable definitions (var, const, let, function arguments, commonjs imports) and ignore things that are already a destructuring assignment. That's it, at least I cannot think of any other valid use for this rule. |
@thealjey Thanks for your input. |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
No error, I guess.
What actually happened? Please include the actual, raw output from ESLint.
The text was updated successfully, but these errors were encountered: