I expect no-unused-vars rule to be skipped if there is an object spread
See original GitHub issueconst { foo, ...rest } = obj;
“foo” is defined but never used happens, but in most case you still want to do this because you want to take obj without some named fields.
I personally would expect the no-unused-vars rule to be skipped if there is an object spread.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:9
- Comments:14 (4 by maintainers)
Top Results From Across the Web
no-unused-vars - ESLint - Pluggable JavaScript Linter
This rule is aimed at eliminating unused variables, functions, and function parameters. A variable foo is considered to be used if any of...
Read more >Ryan Florence på Twitter: "Is there a rule in eslint yet to allow ...
Is there a rule in eslint yet to allow destructuring of unused vars to pluck off ... I expect no-unused-vars rule to be...
Read more >How can I use ESLint no-unused-vars for a block of code?
Original answer · I have tried with no success, the error is thrown by standardjs · Hacking linting rules for something that is...
Read more >eslint-plugin-flowtype - npm
This rule has a string option and an object one. String options are: ... If it is 'always' then a problem is raised...
Read more >Changelog - JavaScript Standard Style
If you have used comments like // eslint-disable-line node/no-deprecated-api you now have to reference the n/ rules instead. object-shorthand rule (as ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nzakas, i agree with @gre that this is not being handled correctly at the moment. for the linter to remain silent when
foo
in the code example above is unused would not be a special affordance, it would be the correct behavior in every instance. the analog is the linter’s behavior in this scenario:the linter does not warn about arg1 being unused, because it accounts for the fact that it may only be present to access arg2. the scenario with a rest spread is exactly the same; because the destructured variables preceding the rest object may only be present to access the rest object, the linter should never complain if they are unused.
If anyone need this just like me today, it`s already possible to do with no-unused-vars: [“error”, { “ignoreRestSiblings”: true }].