Support newline before logical or ternary operator
See original GitHub issueSo I use ternary operators every once in a while, and I format them like the following:
var result = (user === myUser)
? myUser
: defaultUser;
however running this through js-beautify I get
var result = (user === myUser) ? myUser : defaultUser;
I haven’t used the tool much, and didn’t see any relevant options besides the preserve lines but that didn’t help. I understand this is a very narrow use-case and so if the functionality doesn’t exist I’m fine with that.
Thanks for the work put into this library
Issue Analytics
- State:
- Created 9 years ago
- Comments:20 (16 by maintainers)
Top Results From Across the Web
How to make a line break on the Python ternary operator?
You can always extend a logical line across multiple physical lines with parentheses: answer = ( 'Ten for that? You must be mad!...
Read more >java - Line break before/after operator
I believe the line should start with the highest symbol in the parse tree of the statement you want to break. It highlights...
Read more >Ternary conditional operator - Wikipedia
In computer programming, the ternary conditional operator is a ternary operator that is part of the syntax for basic conditional expressions in several ......
Read more >Language Reference - Icinga 2
In general you need to write each statement on a new line. ... The following operators are supported in expressions. ... 1 :...
Read more >Rules - ESLint - Pluggable JavaScript Linter
Possible Problems. These rules relate to possible logic errors in code: ... Disallow assignment operators in conditional expressions. Categories: ✓ Extends.
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
#735 added option to control this.
Also looking for an option to beautify our busy schedules 😃