option to exclude functions from no-unused-vars
See original GitHub issueI want to keep the no-unused-vars
rule as an error, but in an ES2015 module, functions that are not called are considered “unused variables” and trigger the error. I would like to be able to treat functions distinctly (and it would even make most intuitive sense to me for unused rules for variables and named functions to be separate, but I’m aware that’s a gray area).
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
no-unused-vars - ESLint - Pluggable JavaScript Linter
The ignoreRestSiblings option is a boolean (default: false ). Using a Rest Property it is possible to “omit” properties from an object, but...
Read more >Vue: disable no-unused-vars error: the simplest fix
You are using eslint, which add rules to your code, no unused vars is one of them, which means you aren't allowed to...
Read more >The 3 Best ESLint No-Unused-Vars Option Settings (Make it ...
ESLint no-unused-vars ignoreRestSiblings. Removing unused vars helps you comply with the max-lines-per-function rule.
Read more >no-unused-variable - Rule
Rule: no-unused-variable. Disallows unused imports, variables, functions and private class members. Similar to tsc's –noUnusedParameters and –noUnusedLocals ...
Read more >Rule no-unused-vars
This rule is aimed at eliminating unused variables, functions and variables in parameters of functions, as such, warns when one is found.
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 FreeTop 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
Top GitHub Comments
@chrylis your best option is to disable the rule until you want the warning. Put
/*eslint-disable no-unused-vars*/
at the top of your file until you want the warnings again.@jmlopez-rod if it’s really per-function, then you need to manually disable it using inline comments. If you just want arguments to not count, then you can configure that: http://eslint.org/docs/rules/no-unused-vars.html#options
@chrylis I’m sorry, there’s just no good way to distinguish between variables that are functions and variables that are not (given the multiple ways that functions can be defined). I’m afraid introducing such an option would lead to more confusion that it would solve. For now, you can manually disable the rule when you want.