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.

False positive for no-unused-vars when first argument in an array of arguments is unused

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.12.2
  • Node Version: 7.3.0
  • npm Version: 4.0.5

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

root: true
extends: airbnb-base

What did you do? Please include the actual source code causing the issue.

module.exports = (baz, [foo, bar]) => {
  console.log(bar);
};

What did you expect to happen?

I expected foo not to be marked as an unused variable, because it pads bar. Removing foo would alter the behaviour of the code.

What actually happened? Please include the actual, raw output from ESLint.

foo got marked as an unused variable.

$ ./node_modules/.bin/eslint example.js 

/home/remco/d-centralize/appsemble-components/appsemble-build/example.js
  1:25  error    'foo' is defined but never used  no-unused-vars
  2:3   warning  Unexpected console statement     no-console

✖ 2 problems (1 error, 1 warning)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
remcohaszingcommented, Jan 2, 2017

@vitorbal I wasn’t aware this syntax exists, but it makes sense.

Perhaps this could be added as an example to the documentation.

1reaction
vitorbalcommented, Jan 2, 2017

Given you could do something like the following, I’m not entirely sure this should be considered a bug or not:

module.exports = (baz, [, bar]) => {
  console.log(bar);
};
Read more comments on GitHub >

github_iconTop 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 >
ESLint - Configuring "no-unused-vars" for TypeScript
Prior to the change on my side, I had multiple false errors when using interfaces/types saying that these vars were unused (which of...
Read more >
Assigned a Value but Never Used | No Unused Vars - YouTube
In react component I want to display a name but I want to read it from the app state. This name will not...
Read more >
node_modules/@typescript-eslint/eslint-plugin/CHANGELOG ...
eslint-plugin: [no-unnecessary-condition] false positive when array predicate returns unknown (#2772) (111c244) ...
Read more >
Low level issues - Embold Help Center
This rule applies to both array literals and destructuring assignments ... This pattern expects an Error object or null as the first argument...
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