invalid indent with nested ternary in test
See original GitHub issuePrettier 1.14.3 Playground link
--parser babylon
Input:
$var = ($number % 10 >= 2 &&
($number % 100 < 10 || $number % 100 >= 20)
? 1
: 2)
? 0
: 0;
Output:
$var = ($number % 10 >= 2 && ($number % 100 < 10 || $number % 100 >= 20)
? 1
: 2)
? 0
: 0;
Expected behavior:
$var = ($number % 10 >= 2 && ($number % 100 < 10 || $number % 100 >= 20)
? 1
: 2)
? 0
: 0;
Maybe even better output, hard to say what will be looks good, but indent should be don’t loose.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Incorrect indentation on ternary operator with object literal #4203
I was expecting better consistency in alignment between the closing braces & conditional operators. Case with nested ternary expressions & ...
Read more >What is the accepted formatting for nested ternary-operators?
Ternary gives you such a natural testing structure that you can make the code very readable just by making it multiline and indenting...
Read more >Ternary operators are the worst..unless you indent them right!
There's absolutely nothing wrong with nested ternaries.
Read more >no-nested-ternary - ESLint - Pluggable JavaScript Linter
The no-nested-ternary rule disallows nested ternary expressions. Examples of incorrect code for this rule: /*eslint no-nested-ternary: "error"*/ var thing ...
Read more >Clang-Format Style Options — Clang 16.0.0git documentation
The wrapped lines are indented ContinuationIndentWidth spaces from the start of the line. OAS_Align (in configuration: Align ) Horizontally align operands of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
IMO the first two examples should be fixed though.
@evilebottnawi This is intended #5039