Open brodycj opened 3 years ago
I am thinking the workaround in prettierX should be keep the alignment change from the old (replaced) --no-align-ternary-lines
feature in its own option.
I am thinking the workaround in prettierX should be keep the alignment change from the old (replaced)
--no-align-ternary-lines
feature in its own option.
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.
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 https://github.com/prettierx/prettierx-0.4.x-fork/pull/41 & https://github.com/prettierx/prettierx-0.4.x-fork/pull/46.)I made a demo in https://github.com/prettier/prettier/issues/4203#issuecomment-847442620 - 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: https://github.com/prettier/prettier/issues/4203#issuecomment-867213164
Here are some related issues that I found on Prettier itself:
@thorn0
in this comment: https://github.com/prettier/prettier/issues/5811#issuecomment-458948094@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 https://github.com/prettier/prettier/issues/4203#issuecomment-847442620:
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 https://github.com/prettier/prettier/issues/4203#issuecomment-867213164 (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.