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.

Ternary Operator Forced Into Multiple Lines

See original GitHub issue

Input

Ternary operators are forced into multiple lines.

let test = (true) ? true : false;

Expected Output

let test = (true) ? true : false;

Actual Output

let test = (true)
    ? true
    : false;

Settings

{
    "indent_size": 2,
    "indent_char": " ",
    "indent_level": 0,
    "indent_with_tabs": false,
    "preserve_newlines": true,
    "max_preserve_newlines": 2,
    "jslint_happy": false,
    "space_after_anon_function": true,
    "brace_style": "collapse-preserve-inline",
    "keep_array_indentation": false,
    "keep_function_indentation": false,
    "space_before_conditional": true,
    "break_chained_methods": false,
    "eval_code": false,
    "unescape_strings": false,
    "wrap_line_length": 0
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
fdaugancommented, Oct 5, 2016

For your information, I’d to dig into the repository of atom-beautify to find the fix. Add option "preserve_ternary_lines":true in .jsbeautifyrc

See https://github.com/Glavin001/atom-beautify/pull/726

0reactions
gpreslandcommented, Sep 14, 2016

I will move the issue to the atom-beautify repo since the issue appears to be coming from them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to force chop line for ternary operator? - Stack Overflow
But if the ternary operator is all on one line, it won't break it into multiple lines. This can also be achieved by...
Read more >
multiline-ternary - ESLint - Pluggable JavaScript Linter
This rule enforces or disallows newlines between operands of a ternary expression. Note: The location of the operators is not enforced by this...
Read more >
Multiple lines in a ternary operator's clauses? - SitePoint
I'm pretty sure the answer to your question is “no”. The semi-colon is used to indicate the end of the ternary operation, so...
Read more >
How can i use a ternary operator with multiple lines of code
Hi, I am using a ternary operator like the following MyObject has a field "Name" String WebSite = 'Yahoo.com';
Read more >
How to use multiple ternary operators in a single statement in ...
In the above syntax, we have tested 2 conditions in a single statement using the ternary operator. In the syntax, if condition1 is...
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