Unexpected indent error inside template string after ESLint bump from 4.3.0 to 4.4.1
See original GitHub issueTell us about your environment
- ESLint Version: 4.4.1
- Node Version: 8.3.0
- npm Version: 5.3.0
What parser (default, Babel-ESLint, etc.) are you using? babel-eslint
Please show your full configuration:
Configuration
parser: babel-eslint
extends: airbnb
What did you do? Please include the actual source code causing the issue.
const MyComponent = styled.div`
margin: 0;
${(value) => {
noop();
return `
${value}
`;
}}
`; // ← This line triggers an indent error
What did you expect to happen?
I expected no errors.
If the inline arrow function is transformed so the curly braces are removed, the indent error is gone:
const MyComponent = styled.div`
${value => `
${value}
`}
`;
What actually happened? Please include the actual, raw output from ESLint.
Since I updated from ESLint 4.3.0 to 4.4.1, the last line in that template string triggers the indent rule.
9:1 error Expected indentation of 2 spaces but found 0 indent
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
What should I do with "Unexpected indent" in Python?
Expected an indented block. This line of code has the same number of spaces at the start as the one before, but the...
Read more >Unintended indent for multiline template string argument ...
I expected all of the three examples will pass. What actually happened? Please include the actual, raw output from ESLint. 31:1 error Expected ......
Read more >@typescript-eslint/eslint-plugin | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Changelog - JavaScript Standard Style
This pre-release exists to test out the ESLint 8 related changes and discover possible backwards incompatible changes that comes with it and mitigate...
Read more >How do i resolve the unexpected indent error in python
Unindent does not match any outer indentation level. This line of code has fewer spaces at the start than the one before, but...
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 FreeTop 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
Top GitHub Comments
The
indent
rule is supposed to validate your code’s indentation. Previously, it was not doing that in a large number of cases. This was causing a lot of confusion for users, because they were accidentally writing code with incorrect indentation, and expecting theindent
rule to catch it. (In fact, when we rewrote the rule,indent
bugs accounted for about 15% of our open issues.)If you’d like to restore the
indent
behavior from 3.x, you can use theindent-legacy
rule. If you’d like to ignore indentation for code like your example, you can use theMemberExpression: off
option in theindent
rule.Ok, thanks for checking again. I’m going to close this since it doesn’t seem to be an issue with
eslint
.