Disallow nested ternary expressions
❄️ FrozenThis rule is currently frozen and is not accepting feature requests.
Table of ContentsNesting ternary expressions can make code more difficult to understand.
Rule Detailsconst foo = bar ? baz : qux === quxx ? bing : bam;
1
The no-nested-ternary
rule disallows nested ternary expressions.
Examples of incorrect code for this rule:
Open in Playgroundconst thing = foo ? bar : baz === qux ? quxx : foobar; foo ? baz === qux ? quxx() : foobar() : bar();
1
2
3
4
5
Examples of correct code for this rule:
Open in PlaygroundVersionconst thing = foo ? bar : foobar; let otherThing; if (foo) { otherThing = bar; } else if (baz === qux) { otherThing = quxx; } else { otherThing = foobar; }
1
2
3
4
5
6
7
8
9
10
11
12
13
This rule was introduced in ESLint v0.2.0.
ResourcesRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4