> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-nested-ternary

[Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-nested-ternary': 'error',
    },
  },
]);
```

## Rule Details

Disallows nested ternary expressions. Nesting ternary expressions can make code more difficult to understand; prefer an `if` statement or extract the logic into named variables.

Examples of **incorrect** code for this rule:

```javascript
var thing = foo ? bar : baz === qux ? quxx : foobar;

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

Examples of **correct** code for this rule:

```javascript
var thing = foo ? bar : foobar;

var thing;
if (foo) {
  thing = bar;
} else if (baz === qux) {
  thing = quxx;
} else {
  thing = foobar;
}
```

## Original Documentation

- [ESLint: no-nested-ternary](https://eslint.org/docs/latest/rules/no-nested-ternary)
- [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-nested-ternary.js)
