-
Notifications
You must be signed in to change notification settings - Fork 22
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
[prettierx] ternary formatting with objects & tabs needs improvement in upstream Prettier #552
Comments
|
in ternary formatting with objects & tabs ref: - #552
I found another case while working on PR #620, now suspect we may need something more flexible than a boolean option. Further discussion will likely be in issue #585. |
from the following: - #552 - prettier/prettier#4203 (comment)
in ternary formatting with objects & tabs ref: - #552
updated:
While working on PR #492 with simpler balanced ternary formatting, to resolve issue #468, I discovered that the
defaultternary formatting with objects & tabs coming from upstream Prettier could use some improvement. (This does not seem to be an issue with the now removed & replaced--no-align-ternary-lines
option from bangkokjs/prettierx-0.4.x-fork#41 & bangkokjs/prettierx-0.4.x-fork#46.)I made a demo in prettier/prettier#4203 (comment) - see Case 1 below ... now waiting for feedback whether or not it should be in a new issue in Prettier.
Update June 2021: adding Case 2 below with a demo that I reported in: prettier/prettier#4203 (comment)
Here are some related issues that I found on Prettier itself:
@thorn0
in this comment: Extra indent on ternary with long expressions prettier/prettier#5811 (comment)@alexander-akait
: "Prettier has problem with ternary and literal templates when you use tabs, it is very ugly in many cases"See also:
:
)I hope to find a decent workaround when resolving issue #468 for release 0.19.0 (#493).
Case 1
My demo from prettier/prettier#4203 (comment):
From playground, with 8-space tab formatting which is consistent with default formatting on vim/macOS/Linux:
Prettier 2.3.0
Playground link
Input:
Output:
Proposed expected output:
Adapted by replacing each tab character with 4 spaces:
Input:
Output:
Proposed expected output:
Case 2
from prettier/prettier#4203 (comment) (June 2021):
Prettier 2.3.1
Playground link
Input:
Output:
Expected formatting behavior:
I was expecting better consistency in alignment between the closing braces & conditional operators.
with nested ternary expressions & arrays:
Prettier 2.3.1
Playground link
Input:
Output:
Expected formatting behavior:
Better consistency in alignment between the closing brackets & conditional operators.
The text was updated successfully, but these errors were encountered: