Versions

no-nested-ternary

Disallow nested ternary expressions

❄️ Frozen

This rule is currently frozen and is not accepting feature requests.

Nesting ternary expressions can make code more difficult to understand.

const foo = bar ? baz : qux === quxx ? bing : bam;

Rule Details

The no-nested-ternary rule disallows nested ternary expressions.

Examples of incorrect code for this rule:

Open in Playground
/*eslint no-nested-ternary: "error"*/

const thing = foo ? bar : baz === qux ? quxx : foobar;

foo ? baz === qux ? quxx() : foobar() : bar();

Examples of correct code for this rule:

Open in Playground
/*eslint no-nested-ternary: "error"*/

const thing = foo ? bar : foobar;

let otherThing;

if (foo) {
  otherThing = bar;
} else if (baz === qux) {
  otherThing = quxx;
} else {
  otherThing = foobar;
}

Version

This rule was introduced in ESLint v0.2.0.

Resources

Change Language
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy