# no-unnecessary-boolean-comparison

Rule `unicorn/no-unnecessary-boolean-comparison`. Disallow unnecessary comparisons against boolean literals.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #1052 by reach, #1307 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-unnecessary-boolean-comparison` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-unnecessary-boolean-comparison.md) |

## Code examples

### Incorrect: the rule reports this

```js
if ((a > b) === true) {}
```

```js
if ((a > b) === false) {}
```

```js
const active = Boolean(value) !== false;
```

### Correct: the rule accepts this

```js
if (a > b) {}
```

```js
if (!(a > b)) {}
```

```js
const active = Boolean(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/no-unnecessary-boolean-comparison": "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/no-unnecessary-array-flat-map](https://lintradar.dev/rules/unicorn/no-unnecessary-array-flat-map.md): Disallow unnecessary use of `Array#flatMap()`.
- [unicorn/no-unnecessary-parameters](https://lintradar.dev/rules/unicorn/no-unnecessary-parameters.md): Disallow parameters that receive the same value at every call.
- [unicorn/no-undeclared-class-members](https://lintradar.dev/rules/unicorn/no-undeclared-class-members.md): Require class members to be declared.
- [unicorn/no-unsafe-json-serialization](https://lintradar.dev/rules/unicorn/no-unsafe-json-serialization.md): Disallow known values that JSON serialization cannot represent faithfully.
- [unicorn/no-uncalled-method](https://lintradar.dev/rules/unicorn/no-uncalled-method.md): Disallow referencing methods without calling them.
- [unicorn/no-unsafe-property-key](https://lintradar.dev/rules/unicorn/no-unsafe-property-key.md): Disallow unsafe values as property keys.

---

Web page: https://lintradar.dev/rules/unicorn/no-unnecessary-boolean-comparison. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
