Rule option request: `multiline-ternary` to disallow newlines
See original GitHub issueThe 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:
- Created 7 years ago
- Comments:9 (9 by maintainers)
Top 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 >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 >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
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.
I set JSCS Compatibility milestone since JSCS has disallowMultiLineTernary rule.