A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://eslint.org/docs/latest/rules/no-nested-ternary below:

no-nested-ternary - ESLint - Pluggable JavaScript Linter

no-nested-ternary

Disallow nested ternary expressions

❄️ Frozen

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

Table of Contents

Nesting ternary expressions can make code more difficult to understand.

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

1

Rule Details

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

Examples of incorrect code for this rule:

Open in Playground


const 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 Playground


const 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

Version

This rule was introduced in ESLint v0.2.0.

Resources

RetroSearch 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