> 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-ternary

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


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

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

## Rule Details

This rule disallows ternary operators.

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

```javascript
const foo = isBar ? baz : qux;

function quux() {
  return foo ? bar() : baz();
}
```

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

```javascript
let foo;

if (isBar) {
    foo = baz;
} else {
    foo = qux;
}

function quux() {
    if (foo) {
        return bar();
    } else {
        return baz();
    }
}
```

## Original Documentation

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