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.

prefer-const not work with mutiple functions

See original GitHub issue

Tell 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:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
g-planecommented, Oct 31, 2019

Feel free to do this!

0reactions
kaicataldocommented, Nov 4, 2019

Oh, I see - yes, that does look like a bug.

Read more comments on GitHub >

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

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