---
title: "lint/dead-code/no-useless-ternary"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/dead-code/no-useless-ternary" />

In the [`dead-code`](/docs/rules/sets/dead-code) and [`code-quality`](/docs/rules/sets/code-quality) sets. Safe fix.

## What it does

Simplify ternaries whose result does not depend on the condition, or that equal a boolean expression.

## Configuration

```toml title="pun.toml"
[lint.rules]
"dead-code/no-useless-ternary" = "error"
```

To skip it in some files or lines, add an [override](/docs/configuration/pun-toml#lint) or an [ignore comment](/docs/configuration/ignore-comments).

## Options

| Name | Type | Allowed values | Default | Upstream name |
| --- | --- | --- | --- | --- |
| `checks` | `list` | `bool`, `tautology`, `useless` | `["bool", "tautology", "useless"]` | None (Pun's own) |

## Replaces

- [`RemoveUselessTernary`](https://getrector.com/rule-detail/remove-useless-ternary-rector) (rector)
- [`SimplifyTautologyTernary`](https://getrector.com/rule-detail/simplify-tautology-ternary-rector) (rector)
- [`UnnecessaryTernaryExpression`](https://getrector.com/rule-detail/unnecessary-ternary-expression-rector) (rector)

## Merged rules

These old IDs are now this rule. A config that still names one stops with an error. See [merged rules](/docs/migrate/merged-rules).

- `lint/dead-code/no-bool-ternary`
- `lint/dead-code/no-tautology-ternary`

[More lint/dead-code rules](/docs/rules/lint/dead-code) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
