no-unused-vars flags global variables sometimes when it should not
See original GitHub issueI am getting numerous errors like the following:
8:4 warning formatters is defined but never used no-unused-vars
when “formatters” is a global Object variable defined as follows:
var formatters = {
...
} ;
In my .eslintrc, I have this rule:
"no-unused-vars": [1, {"vars": "local", "args": "none"}], // default: [2, {"vars": "all", "args": "after-used"}]
Shouldn’t the {“vars”: “local”} option cause no error or warning to be output for the global “formatters” variable?
In addition, I have this in my .eslintrc:
"globals": {
"formatters": true
}
Shouldn’t this also cause the “formatters” variable to be ignored (even if I didn’t have the rule above)?
I am using eslint 0.16.1.
Issue Analytics
- State:
- Created 9 years ago
- Comments:17 (11 by maintainers)
Top 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 >Global variables in Javascript and ESLint - Stack Overflow
I have got multiple javascript files and I have defined some global variable in a file which loads before the others.
Read more >How to disable "no-unused-vars" in Visual Studio Code (or at ...
All I want is to turn off this feature or for it to simply flag unused variables as warnings (not errors). Any advice...
Read more >Google C++ Style Guide
Global and static variables are very useful for a large number of applications: named constants, auxiliary data structures internal to some translation unit, ......
Read more >Numeric and String Variables
Since the /G flag was not specified, these variables would be global if you invoked the Variable operation directly from the command line...
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
No problem, I actually was wondering if maybe you were using ESLint through an intermediary. In any event, glad it got fixed.
@nzakas I was going to name my project jscop before I saw that eslint used exactly the same approach:-)