# prefer-includes-over-repeated-comparisons

Rule `unicorn/prefer-includes-over-repeated-comparisons`. Prefer `.includes()` over repeated equality comparisons.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #1069 by reach, #1324 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/prefer-includes-over-repeated-comparisons` | no | no | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/prefer-includes-over-repeated-comparisons.md) |

## Code examples

### Incorrect: the rule reports this

```js
value === 'a' || value === 'b' || value === 'c';
```

```js
args[0] === '-h' || args[0] === '--help' || args[0] === '--version';
```

```js
value !== 'a' && value !== 'b' && value !== 'c';
```

### Correct: the rule accepts this

```js
['a', 'b', 'c'].includes(value);
```

```js
['-h', '--help', '--version'].includes(args[0]);
```

```js
!['a', 'b', 'c'].includes(value);
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/prefer-includes-over-repeated-comparisons": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/prefer-https](https://lintradar.dev/rules/unicorn/prefer-https.md): Prefer HTTPS over HTTP.
- [unicorn/prefer-iterator-to-array](https://lintradar.dev/rules/unicorn/prefer-iterator-to-array.md): Prefer `Iterator#toArray()` over temporary arrays from iterator spreads.
- [unicorn/prefer-hoisting-branch-code](https://lintradar.dev/rules/unicorn/prefer-hoisting-branch-code.md): Prefer moving code shared by all branches of an `if` statement out of the branches.
- [unicorn/prefer-location-assign](https://lintradar.dev/rules/unicorn/prefer-location-assign.md): Prefer `location.assign()` over assigning to `location.href`.
- [unicorn/prefer-group-by](https://lintradar.dev/rules/unicorn/prefer-group-by.md): Prefer `Object.groupBy()` or `Map.groupBy()` over manual grouping.
- [unicorn/prefer-number-is-safe-integer](https://lintradar.dev/rules/unicorn/prefer-number-is-safe-integer.md): Prefer `Number.isSafeInteger()` over integer checks.

---

Web page: https://lintradar.dev/rules/unicorn/prefer-includes-over-repeated-comparisons. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
