no-unused-var exception when destructuring?
See original GitHub issueIn the code below (es6), eslint throws an no-unused-var error on the _
argument:
return this._getProperties()
.filter(([ prop ]) => prop.isDirty())
.map(([ _, propName ]) => propName);
When destructuring, it is a common to use _
to denote variables that won’t be used. Would there a way for eslint to ignore those kinds of unused variables?
See https://github.com/airbnb/javascript/issues/435
eslint v0.24.1
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Omit property variable when using object destructuring
We're omitting property a from the object, but then const a is assigned a value, but never used - error from eslint (no-unused-vars)....
Read more >no-unused-vars - ESLint - Pluggable JavaScript Linter
The destructuredArrayIgnorePattern option specifies exceptions not to check for usage: elements of array destructuring patterns whose names match a regexp ...
Read more >node_modules/eslint/CHANGELOG.md - GitLab
... 5668236 Fix: Allow objectsInObjects exception when destructuring ... ed5564f Docs: Specify results of no-unused-var with args (fixes ...
Read more >How To Turn Off Eslint Tyfedef Rule For Destructuring In Lambdas
This rule enforces usage of destructuring instead of accessing a property through a ... Error '500' { exception } ; } diff git...
Read more >Diff - 402e1b6e55e9041dfd1a93580e45e5c5dba1db55^!
... Allow objectsInObjects exception when destructuring (fixes #6469) ... +* ed5564f Docs: Specify results of `no-unused-var` with `args` ...
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 Free
Top 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
Reopen this? It’s still an issue IMO.
var [,,, w] = produce_vector()
is not as clear code as
var [ _x, _y, _z, w] = produce_vector()
when you want to clearly see that
w
is indeedw
.that’s “args ignore pattern”; wouldn’t a destructuring need a “vars ignore pattern”? Also I think if you enable the
ignoreRestSiblings
option it will work.