Skip to content

curly 'multi' autofix produces syntax errors with lexical declarations  #11908

@mdjermanovic

Description

@mdjermanovic

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: {
    "curly": ["error", "multi"]
  }
};

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

if (foo) {
  let bar;
}
eslint index.js --fix

What did you expect to happen?

No errors, similar to how multi-or-nest works.

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

if (foo) 
  let bar; // SyntaxError: Lexical declaration cannot appear in a single-statement context

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

Yes.

Metadata

Metadata

Assignees

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