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

arrow-body-style autofix errors with sequence expression #11917

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

@mdjermanovic
Copy link
Member

Tell us about your environment

  • ESLint Version: 6.0.1 (same with 5.16.0)
  • Node Version: 10.16.0
  • npm Version: 6.9.0

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

default

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
    ecmaVersion: 6,
  },
  rules: {
    "arrow-body-style": "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.

First example:

const foo = () => { return bar, baz; };

Second example:

const a = 1;
if (true) {
  let foo = () => { return bar, a; };
  console.log(a); // 1
}
eslint index.js --fix

What did you expect to happen?

Not a syntax error or changed semantics.

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

const foo = () => bar, baz; // SyntaxError: Missing initializer in const declaration
const a = 1;
if (true) {
  let foo = () => bar, a;
  console.log(a); // undefined
}

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

Yes

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jun 28, 2019
@g-plane
Copy link
Member

g-plane commented Jun 28, 2019

Should we add parens at this case?

@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jun 28, 2019
@mysticatea
Copy link
Member

Thank you for your report.

I confirmed it: online demo

I agree that we should parenthesize the body in that case as same as () => { return { bar, baz }; } case.

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