Indentation is too aggressive for ternary operator
See original GitHub issueActual:
var v =
0 ? 1 :
2 ? 3 :
4;
Expected:
var v =
0 ? 1 :
2 ? 3 :
4;
I believe the fix is that if the false branch of the ternary operator should have the same indentation as the true branch. In the case where the true branch is on the same line as the condition, it should not be considered indented, and therefore the false branch should not be indented.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:18
- Comments:6 (4 by maintainers)
Top Results From Across the Web
ternary operator (?:) wrong indent : IDEA-157071 - YouTrack
I suppose there is an issue with code auto reformatting. The JCC (Java Code Convensions) said how the ternary operator (?:) line breaking...
Read more >I shall never give up on forcing ternary statements down my ...
I only use ternary operators for assignments if it's very short and obvious how the assignment is working: string username = user.
Read more >How should I indent ternary conditional operator in python so ...
The first is more readible. · (1) PEP 8 prefers parentheses over backslashes for expressions spanning several lines. · Unfortunately, questions ...
Read more >Maintainable JavaScript - Javascript - 50 - Passei Direto
Basic Formatting Indentation Levels Statement Termination Line Length Line ... Naming Strict Mode Assignments Equality Operators Ternary Operator Statements ...
Read more >Joytran: Timeline - Chisel
switch from K&R style indentation to Lisp style indentation (I don't care for ... including a switch to ternary operator if/else statements in...
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
Does the team still want to fix this? In other words, will the team merge my PR if I revive #5905?
I think that’s the right question to ask here. Let’s try to stay close to other languages service teams. If it turns out there are shortcomings, then they should know too.