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 produces invalid autofix when using destructuring with multiple declarators #11699

Closed
not-an-aardvark opened this issue May 10, 2019 · 3 comments

Comments

@not-an-aardvark
Copy link
Member

commented May 10, 2019

Tell us about your environment

  • ESLint Version: master
  • Node Version: 12.1.0
  • npm Version: 6.9.0

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
rules:
  prefer-const: error

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

let {a, b} = c, d;
eslint --fix

What did you expect to happen?

I expected ESLint to not create a syntax error.

What actually happened? Please include the actual, raw output from ESLint.

ESLint produced the following autofixed code, which has a syntax error:

const {a, b} = c, d;

Demo link

This was discovered when running the fuzzer locally.

Are you willing to submit a pull request to fix this bug?

Yes, but I'm not sure when I'll have time.

@g-plane

This comment has been minimized.

Copy link
Member

commented May 10, 2019

Should we disable autofix at this case or split it into two statements?

@mysticatea

This comment has been minimized.

Copy link
Member

commented May 10, 2019

I think that disabling autofix is good enough.

@mdjermanovic

This comment has been minimized.

Copy link
Member

commented Jun 11, 2019

Similar bugs:

let {a, b, c} = {}, e, f;
let {a, b} = {}, c = 0;
c = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.