-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
End of multiline ternary expressions not aligned with colon anymore when using tab indentation #15783
Comments
Alternative formatting that would look okay (IMO):
There was an experimental change (later reverted) in #15662 that would have produced this formatting, but it went too far, also changing cases like
to
As I commented there, I think it's only safe to use tabs after non-tab characters if it's after a single, tab-aligned character (like |
Technically I guess it's impossible to be fully consistent using tabs, if you consider a tab width of 1 space: condition
? exprIfTrue
: {
exprIfFalse,
}; But I doubt anyone actually uses a tab width of 1, and it works with a tab width of 2 and higher: condition
? exprIfTrue
: {
exprIfFalse,
}; |
This is fixed by #15662. Please wait next release Prettier pr-15662 --parser babel
--use-tabs Input: condition ? exprIfTrue : {
exprIfFalse
}; Output: condition
? exprIfTrue
: {
exprIfFalse,
}; |
I'm confused, didn't that PR make it into Prettier v3.1.1, which this bug report is for? And I see the same output in both playgrounds: condition
? exprIfTrue
: {
exprIfFalse,
}; |
@sosukesuzuki This is still an issue in v3.2.1, could you please reopen? 🙏 |
Thanks for flagging this @paescuj! I can still observe misaligned Prettier 3.2.1 --parser babel
--use-tabs Input: condition ? exprIfTrue : {
exprIfFalse
}; Output: condition
? exprIfTrue
: {
exprIfFalse,
}; Expected output: condition
? exprIfTrue
: {
exprIfFalse,
}; Reopening for further investigation. |
Why is the expected output with tabs instead of spaces after
|
I really wish that #15662 was reverted, or at a minimum be able to turn it off -- it is what is causing us to have to stick on
Can this be turned off, opt-out, or reverted? |
Prettier 3.1.1
Playground link
Input:
Output:
Ends with a hard tab and is not aligned with the colon anymore (same goes for truthy expression):
Expected behavior:
Should end with a soft indent to be aligned with colon, as before with
prettier@3.1.0
:Most likely related to #15662.
Thanks for your work ❤️
The text was updated successfully, but these errors were encountered: