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.

no-unused-vars flags global variables sometimes when it should not

See original GitHub issue

I 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:closed
  • Created 9 years ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Mar 13, 2015

No problem, I actually was wondering if maybe you were using ESLint through an intermediary. In any event, glad it got fixed.

0reactions
ilyavolodincommented, Mar 13, 2015

@nzakas I was going to name my project jscop before I saw that eslint used exactly the same approach:-)

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 >
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 >

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