Deeply nested ternary expressions are hard to read and easy to misinterpret. This rule is an improved version of ESLint’s built-inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt
Use this file to discover all available pages before exploring further.
no-nested-ternary rule: instead of banning all nesting, it allows a single level of nesting as long as the inner ternary is wrapped in parentheses, which makes the structure explicit.
| Recommended | ✅ recommended |
| Fixable | 🔧 Auto-fixable |
| Suggestions | — |
Autofix behavior
The rule can automatically fix the case where a nested ternary is one level deep but missing parentheses:Replacing the built-in rule
Disable ESLint’s built-inno-nested-ternary rule in favor of this one. The recommended preset from eslint-plugin-unicorn already does this for you.