Incorrect indentation inside inline map function
See original GitHub issuePrettier 1.14.3 Playground link
Input:
var w = sites ? null : sites.map(({ node: site }) => (
<li key={site.lang}>
<a href={site.url}>{site.name}</a>
</li>
));
Output:
var w = sites
? null
: sites.map(({ node: site }) => (
<li key={site.lang}>
<a href={site.url}>{site.name}</a>
</li>
));
Expected behavior:
Why indentation before <li>
is 2+4=6
symbols? I would expect to see 2+2=4
symbols.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
I'm getting an IndentationError. How do I fix it? - Stack Overflow
The fix for this error is to simply include a body for the compound statement. As shown above, a common mistake by new...
Read more >Indentation Error in Python | How to Solve it - Edureka
This article will provide you with a detailed understanding of Indentation error in Python and the solutions to avoid the same.
Read more >TabError inconsistent use of tabs and spaces in indentation
When the code is executed, the “TabError inconsistent use of tabs and spaces in indentation”. This occurs when the code has all the...
Read more >Optional Braces - Scala 3 - EPFL
It is an error if the indentation width of the token following an <outdent> does not match the indentation of some previous line...
Read more >F# code formatting guidelines | Microsoft Learn
When indentation is required, you must use spaces, not tabs. F# code doesn't use tabs, and the compiler will give an error if...
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
All of the previous discussions linked above have been locked, unfortunately. We’re running into the same problem as we’re testing out Prettier’s effects. We use tabs, which makes the problem even worse:
Notice that the properties are indented twice with tabs, and the closing braces are indented an extra two spaces. This really bummed us because we wanted to start using Prettier, but this is not prettier.
Running into the same issue with tabs. The properties are being double indented, which hurts the readability.
The idea behind the rule seems to be that
}
should align with{
. But every other formatting rule involving brackets do not align these (if, for, while, switch, plain object assign statements, etc.). And it’s very specific to the “2 space indent” rule.