-
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?
Changes from 5 commits
ea4ec7f
a141e49
c81099e
8fef2ec
9c88a28
d00e6b5
a7e7612
03a79c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,13 @@ let isSpace = false; | |
|
||
const dress = isSpace | ||
? { | ||
spaceSuit: 3, | ||
oxygenCylinders: 6 | ||
} | ||
spaceSuit: 3, | ||
oxygenCylinders: 6 | ||
} | ||
: { | ||
shirts: 3, | ||
paints: 3 | ||
}; | ||
shirts: 3, | ||
paints: 3 | ||
}; | ||
|
||
================================================================================ | ||
`; | ||
|
@@ -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 | ||
}; | ||
|
||
================================================================================ | ||
`; | ||
|
@@ -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 | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 P.S. I think this observation is a manifestation of issue #552, as I reported in this comment: prettier/prettier#4203 (comment) |
||
|
||
================================================================================ | ||
`; | ||
|
@@ -133,13 +133,13 @@ let isSpace = false; | |
|
||
const dress = isSpace | ||
? { | ||
spaceSuit: 3, | ||
oxygenCylinders: 6 | ||
} | ||
spaceSuit: 3, | ||
oxygenCylinders: 6 | ||
} | ||
: { | ||
shirts: 3, | ||
paints: 3 | ||
}; | ||
shirts: 3, | ||
paints: 3 | ||
}; | ||
|
||
================================================================================ | ||
`; | ||
|
@@ -224,8 +224,8 @@ function test1() { | |
? Promise(1) | ||
: Promise(2) | ||
: condition3 | ||
? Promise(3) | ||
: Promise(4); | ||
? Promise(3) | ||
: Promise(4); | ||
} | ||
|
||
================================================================================ | ||
|
@@ -268,8 +268,8 @@ function test1() { | |
? Promise(1) | ||
: Promise(2) | ||
: condition3 | ||
? Promise(3) | ||
: Promise(4); | ||
? Promise(3) | ||
: Promise(4); | ||
} | ||
|
||
================================================================================ | ||
|
@@ -313,8 +313,8 @@ function test1() { | |
? Promise(1) | ||
: Promise(2) | ||
: condition3 | ||
? Promise(3) | ||
: Promise(4); | ||
? Promise(3) | ||
: Promise(4); | ||
} | ||
|
||
================================================================================ | ||
|
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
: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