question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect indentation inside inline map function

See original GitHub issue

Prettier 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:open
  • Created 5 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
robyodercommented, Oct 24, 2019

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:

2019 10 24 13 35 22

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.

4reactions
lukescottcommented, Oct 30, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found