-
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
[WIP] prettierx refactor!: fix & update balanced ternary formatting support - DRAFT WIP #620
base: dev
Are you sure you want to change the base?
Conversation
in ternary formatting with objects & tabs ref: - #552
…brodybits/prettierx into update-balanced-ternary-formatting-support include update from: - #492 (brodybits/prettierx PR #492)
const dress = isSpace | ||
? { | ||
spaceSuit: 3, | ||
oxygenCylinders: 6 | ||
} | ||
spaceSuit: 3, | ||
oxygenCylinders: 6 | ||
} | ||
: { | ||
shirts: 3, | ||
paints: 3 | ||
}; | ||
shirts: 3, | ||
paints: 3 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a closer look at some snapshot changes at this point with update from PR #492, with tabWidth: 4
:
@@ -60,13 +60,13 @@ let isSpace = false;
const dress = isSpace
? {
- spaceSuit: 3,
- oxygenCylinders: 6
- }
+ spaceSuit: 3,
+ oxygenCylinders: 6
+ }
: {
- shirts: 3,
- paints: 3
- };
+ shirts: 3,
+ paints: 3
+ };
================================================================================
`;
The alignment of the inner object members in this diff felt little off to me with my magnified terminal font. I think this is because the inner object members have an indentation of 10 spaces, while most of the other lines have an indentation of 4 or 6 spaces.
I am now thinking that it would be best to use an option to remove the ternary indenting, like "--no-ternary-inner-indent" as discussed in #585 in case of tab width > 2 spaces or --use-tabs
option.
P.S. I think this comment is a manifestation of this issue: prettier/prettier#4203
const dress = isSpace | ||
? { | ||
spaceSuit: 3, | ||
oxygenCylinders: 6 | ||
} | ||
spaceSuit: 3, | ||
oxygenCylinders: 6 | ||
} | ||
: { | ||
shirts: 3, | ||
paints: 3 | ||
}; | ||
shirts: 3, | ||
paints: 3 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the diff from my terminal with display tab width of 8:
@@ -96,13 +96,13 @@ let isSpace = false;
const dress = isSpace
? {
- spaceSuit: 3,
- oxygenCylinders: 6
- }
+ spaceSuit: 3,
+ oxygenCylinders: 6
+ }
: {
- shirts: 3,
- paints: 3
- };
+ shirts: 3,
+ paints: 3
+ };
================================================================================
`;
I think a workaround like using a "--no-ternary-inner-indent" option as discussed in #585 is clearly needed when using the balanced ternary formatting option together with --use-tabs
.
P.S. I think this observation is a manifestation of issue #552, as I reported in this comment: prettier/prettier#4203 (comment)
… into update-balanced-ternary-formatting-support
…ommit notes below (...) * Revert "prettierx: fix balanced ternary formatting, with a simpler solultion" This reverts commit ea4ec7f. * Revert "update test snapshots in tests/ternaries/with-balanced-formatting (...)" This reverts commit 8fef2ec. ADDING COMMIT NOTES: The following statements for GitHub should not be considered valid at this point: > The changes from these updates close [issue number] 492 (brodybits/prettierx PR [number] 492). > resolved [sic] [issue number] 468 (brodybits/prettierx issue [number] 468) Some more testing & consideration is needed before moving forward with a solution in this or another PR.
0c6ebbc
to
cf25e85
Compare
hello @brodybits |
(BREAKING CHANGE)
resolves #468
Status: DRAFT WIP
TODO: