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.

Rule option request: `multiline-ternary` to disallow newlines

See original GitHub issue

The multiline-ternary rule allows me to require ternaries to be multiline - I’d like an option that requires ternaries not be multiline.

What version of ESLint are you using? v3.1.1

What rule do you want to change? multiline-ternary, I’d like a “disallowMutliline” option added.

What code should be flagged as incorrect with this change?

var x = a ?
  b :
  c;

var y = a
  ? b
  : c;

var z = a ? b :
  c;

What happens when the rule is applied to this code now? It passes.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
kaicataldocommented, Jul 27, 2016

Interestingly enough, this was discussed and we ended up deciding to only implement “always”. I’m happy to add this in if/when it’s accepted. Assigning myself now so I don’t lose track of it.

2reactions
mysticateacommented, Jul 27, 2016

I set JSCS Compatibility milestone since JSCS has disallowMultiLineTernary rule.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Multiline-ternary - ESLint - W3cubDocs
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 >
vue/multiline-ternary
Enforce newlines between operands of ternary expressions in ` `
Read more >
Multiline Ternary - Unibeautify
Enforces new lines between the operands of a ternary expression. Configuration option for beautifiers Pretty Diff and languages C#, EJS, JSX, Java, ...
Read more >
要求或禁止在三元操作数中间换行(multiline-ternary) - ESLint
Examples of correct code for this rule with the "always-multiline" option: /*eslint multiline-ternary: ["error", "always-multiline"]*/ foo > bar ? value1 ...
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