question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-unused-var exception when destructuring?

See original GitHub issue

In 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:closed
  • Created 8 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
unphasedcommented, Nov 25, 2017

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 indeed w.

1reaction
ljharbcommented, Jan 31, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found