no-unused-vars error message should provide hint on ignorePattern.
See original GitHub issueWe 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:
- Created 6 years ago
- Reactions:3
- Comments:9 (9 by maintainers)
Top 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 >
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
@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.
It looks like we missed the
fixes
message on the PR. This was closed in https://github.com/eslint/eslint/pull/9176.