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-vars error message should provide hint on ignorePattern.

See original GitHub issue

We use no-unused-vars but provide allowed patterns for ignored vars and args.

"no-unused-vars": [1, {"vars": "all", varsIgnorePattern: "^_", "args": "all", "argsIgnorePattern": "^_"}],

With this code:

/* eslint no-unused-vars: [2, {"vars": "all", varsIgnorePattern: "^_", "args": "all", "argsIgnorePattern": "^_"}] */

[1,2,3].map((item, index, array) => {
  return item / array.length;

We get this error:

3:20 - 'index' is defined but never used. (no-unused-vars)

It is unreasonable for our engineers to be aware of our allowed pattern in the configuration and this warning will instead cause people to go through lots of work and confusion to get eslint to pass, or they will just turn it off.

I think a more valuable warning message would be something like this:

3:20 - 'index' is defined but never used. If this is intentional, consider matching the allowed unused argument pattern /^_/ (no-unused-vars)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

platinumazurecommented, Aug 30, 2017

@TheSavior We will accept the issue when enough people on the ESLint core team have supported the issue that we have reached consensus. This means one champion and three 👍s from other team members.

I’ll champion. So we need two more 👍s (mine no longer counts).

@eslint/eslint-team Anyone else want to support this? I think this would be a small but very useful improvement to the messaging for this rule.

kaicataldocommented, Oct 13, 2017

It looks like we missed the fixes message on the PR. This was closed in

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable warn about some unused params, but keep ...
Only way that I found is to use ignore pattern argsIgnorePattern in rule options. If your variable is unused, just add underscore _ctx...
Read more >
no-unused-vars - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
vue3 how to disable no-unused-vars in callback : r/vuejs - Reddit
i tried that and it the error dissapear but the code now broken, without the res => the callback is called instantly and...
Read more >
A Complete Guide to Using TypeScript in Node.js - Better Stack
All the "implicit any" errors should be gone now as the compiler can automatically recognize the newly installed types and check your code...
Read more >
parsing error: 'const declarations' require an initialization ...
Are you willing to submit a pull request to fix this bug? No, I didn't investigate the ESLint source code. Open side panel....
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 Post

No results found

github_iconTop Related Hashnode Post

No results found