noNestedTernary
このコンテンツはまだ日本語訳がありません。
Diagnostic Category: lint/nursery/noNestedTernary
Since: v1.9.3
Sources:
- Same as:
no-nested-ternary
Disallow nested ternary expressions.
Nesting ternary expressions can make code more difficult to understand.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:27 lint/nursery/noNestedTernary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Do not nest ternary expressions.
> 1 │ const thing = foo ? bar : baz === qux ? quxx : foobar;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Nesting ternary expressions can make code more difficult to understand.
ℹ Convert nested ternary expression into if-else statements or separate the conditions to make the logic easier to understand.
code-block.js:1:7 lint/nursery/noNestedTernary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Do not nest ternary expressions.
> 1 │ foo ? baz === qux ? quxx() : foobar() : bar();
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Nesting ternary expressions can make code more difficult to understand.
ℹ Convert nested ternary expression into if-else statements or separate the conditions to make the logic easier to understand.