curly 'multi' autofix produces syntax errors with lexical declarations
See original GitHub issueTell 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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (16 by maintainers)
Top Results From Across the Web
Rules - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >eslint/CHANGELOG.md
... curly `multi` reports single lexical declarations (fixes #11908) (#12513) ... prefer-template autofix produces syntax error with octal escapes (#12085) ...
Read more >node_modules/eslint/CHANGELOG.md · master · tbrousso ...
... Fix: curly multi reports single lexical declarations (fixes #11908) (#12513) (Milos Djermanovic); ac60621 Fix: unexpected autofix in ...
Read more >Syntax Errors in Coding and What You Can Do to Fix Them
A syntax error commonly occurs in coding when the coder has typed in something incorrectly. Syntax errors are easy to find and fix....
Read more >PHP parse/syntax errors; and how to solve them
Which often occurs in multi-line and nested array declarations. $array = [1,[2,3],4,[5 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s most likely a bad practice to have a function declaration anywhere other than directly in the body.
Perhaps ESLint should never modify such code, i.e. never move function declarations to
{}
or out from its existing{}
, because it can produce some unpredictable differences even if it isn’t a syntax error.Ok, I’m working on this.
It might take some time, all options have to be checked and the
consistent
modifier adds some complexity.