`no-unused-vars` should not flag constants declared with `const`
See original GitHub issueWhat version of ESLint are you using? 2.9.0
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
{
"env": {
"browser":true,
"es6":true
},
"plugins": [
"html"
],
"rules": {
"no-mixed-spaces-and-tabs":[2, true],
"no-redeclare":2,
"no-use-before-define":[2, "nofunc"],
"no-unused-vars":1,
"no-undef":2,
"eqeqeq":2,
"consistent-return":1,
"radix":2,
"console":0,
"camelcase":0,
"strict":0,
"quotes":[2, "double", "avoid-escape"],
"new-cap":0,
"space-infix-ops":0,
"no-console":0,
"no-delete-var":0,
"no-underscore-dangle":0,
"no-multi-spaces":0,
"dot-notation":[2, {"allowKeywords": false}],
"space-unary-ops":1,
"key-spacing": [1, {"beforeColon": false, "afterColon": true, "mode": "minimum"}],
"no-empty":2,
"brace-style": [1, "stroustrup", { "allowSingleLine": true }],
"keyword-spacing": 2,
"no-space-before-semi": 0,
"space-before-function-paren": [2, "never"],
"no-trailing-spaces": [2, { "skipBlankLines": false }],
"prefer-const": ["error"]
}
}
What did you do? Please include the actual source code causing the issue.
const EDGE_OFFSET = 15;
What did you expect to happen?
No warnings since EDGE_OFFSET
is a constant, not a variable.
What actually happened? Please include the actual, raw output from ESLint.
minimum.js
1:7 warning 'EDGE_OFFSET' is defined but never used no-unused-vars
✖ 1 problem (0 errors, 1 warning)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (3 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 >tslint how to disable error "someVariable is declared but its ...
Any parameter name starting with _ is exempt from the check. Use _myVariable instead of myvariable to remove this warning.
Read more >How to fix Definition for rule typescript-eslint no-use-before ...
I am new to eslint and I cannot figure out how to solve this issue. The beginning of my imports is always underlined...
Read more >Disallow modifying variables that are declared using const (no ...
This rule is aimed to flag modifying variables that are declared using const keyword. Examples of incorrect code for this rule: /*eslint no-const-assign:...
Read more >How to disable "no-unused-vars" in Visual Studio Code (or at ...
I honestly do not think that an unused variable or parameter is on the same level as, say, trying to reassign a constant....
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
So you are arguing semantics of the name of the rule? Const is a read-only variable (not really completely true in JS, but that’s what it is in other languages).
Of course I’m not familiar with your codebase and conventions, but nowadays it’s common to use
const
everywhere, not just for actual (global) constants. If I need alet
(orvar
) I will rewrite my code to not need alet
. In general I write all my code in an immutable fashion, soconst
is the only way to go. This means not just my contants (for example Redux action types) will useconst
, but also any other variables.What I’m trying to say is, don’t hold on too tight to your ALL_CAPS convention. It generally doesn’t help readability if your code is sprinkled with all caps.