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

Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@not-an-aardvark
Copy link
Member

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.

@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion labels May 10, 2019
@g-plane
Copy link
Member

g-plane commented May 10, 2019

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

@mysticatea
Copy link
Member

I think that disabling autofix is good enough.

@mdjermanovic
Copy link
Member

Similar bugs:

let {a, b, c} = {}, e, f;
let {a, b} = {}, c = 0;
c = 1;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.