---
title: "lint/style/prefer-short-ternary"
pagination: false
---

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

<RuleId id="lint/style/prefer-short-ternary" />

Not in any set. Unsafe fix: it can change behaviour.

## What it does

Use the Elvis operator `?:` where possible.

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/prefer-short-ternary" = "error"
```

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

## Replaces

- [`ternary_to_elvis_operator`](https://cs.symfony.com/doc/rules/operator/ternary_to_elvis_operator.html) (php-cs-fixer, risky)

## Linked rules

- Conflicts with [`lint/style/no-short-ternary`](/docs/rules/lint/style/no-short-ternary). You cannot enable both.

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