Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer-const not work with mutiple functions #12514

Closed
rupertqin opened this issue Oct 31, 2019 · 8 comments · May be fixed by rsumner868/librealsense2.1#1, rsumner868/librealsense#4, O330oei/node#4 or O330oei/node#11
Closed

Comments

@rupertqin
Copy link

@rupertqin rupertqin commented Oct 31, 2019

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.

@g-plane
Copy link
Member

@g-plane g-plane commented Oct 31, 2019

It seems that I can't reproduce via online demo.

Can you tell us more detail?

@rupertqin
Copy link
Author

@rupertqin rupertqin commented Oct 31, 2019

@g-plane try this

function a() {
  let foo = 0,
    bar = 1;
  foo = 1;
}
function b() {
  let foo = 0,
    bar = 1;
  foo = 1;
}
function c() {
  let foo = 0,
    bar = 1;
  foo = 1;
}
@g-plane
Copy link
Member

@g-plane g-plane commented Oct 31, 2019

Reproduced. Online demo.

@g-plane g-plane added accepted rule and removed triage labels Oct 31, 2019
@yeonjuan
Copy link
Member

@yeonjuan yeonjuan commented Oct 31, 2019

May I try this on?

@g-plane
Copy link
Member

@g-plane g-plane commented Oct 31, 2019

Feel free to do this!

@kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Nov 1, 2019

@g-plane Can you explain what the bug here is? I'm not sure I understand why the above code being flagged is incorrect.

@g-plane g-plane added the autofix label Nov 2, 2019
@g-plane
Copy link
Member

@g-plane g-plane commented Nov 2, 2019

The bug is about autofix, while problem reports work as intended.

@kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Nov 4, 2019

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

@eslint eslint bot locked and limited conversation to collaborators May 4, 2020
@eslint eslint bot added the archived due to age label May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.