Skip to content

prefer-const not work with mutiple functions #12514

@rupertqin

Description

@rupertqin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionautofixThis change is related to ESLint's autofixing capabilitiesbugESLint is working incorrectlyruleRelates to ESLint's core rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions