question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support newline before logical or ternary operator

See original GitHub issue

So 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:closed
  • Created 9 years ago
  • Comments:20 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
bitwisemancommented, Feb 3, 2016

#735 added option to control this.

0reactions
ghostcommented, Dec 5, 2015

Also looking for an option to beautify our busy schedules 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found