prefer-const not work with mutiple functions
See original GitHub issueTell us about your environment
Node version: v10.16.3 npm version: v6.12.0 Local ESLint version: v6.6.0 Global ESLint version: v6.6.0
What did you expect to happen?
rule of prefer-const
mess up in multiple function.
the config is:
"prefer-const": [
"warn",
{
"destructuring": "all",
"ignoreReadBeforeAssign": true
}
],
file a.js
function a (){
let foo =0;
foo = 1;
}
function b (){
let foo =0;
foo = 1;
}
function c (){
let foo =0;
foo = 1;
}
will eslint --fix
output as
function a (){
let foo =0;
foo = 1;
}
function b (){
const foo =0;
foo = 1;
}
function c (){
const foo =0;
foo = 1;
}
Are you willing to submit a pull request to fix this bug?
Can’t help with resolution.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
prefer-const - 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 >ESLint: prefer-const doesn't throw an error even if variable is ...
In my . eslintrc file, the value of prefer-const has been set to 2 and I do not override rules in the file....
Read more >Prefer const, then let - JavaScript Video Tutorial - LinkedIn
Identifiers like functions are an obvious choice. In my eslint RC file, I'll add another line to the rules section, and add prefer-const...
Read more >const - JavaScript - MDN Web Docs - Mozilla
A constant cannot share its name with a function or a variable in the same scope. Unlike var , const begins declarations, not...
Read more >5 Best Practices to Write Quality JavaScript Variables
5 best practices on how to write quality JavaScript variables: prefer const, minimize scope, close to use place, and more.
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
Feel free to do this!
Oh, I see - yes, that does look like a bug.