# const-comparisons

Rule `oxc/const-comparisons`. Checks for redundant or logically impossible comparisons. This includes: - Ineffective double comparisons against constants. - Impossible comparisons involving constants. - Redundant comparisons where both operands are the same (e.g., a < a).

- Source: oxc
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 81.4M weekly downloads of presets that enable it
- Trend: +150.3% last quarter
- Rank: #220 by reach, #73 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Oxlint | `oxc/const-comparisons` | yes | no | plugin `oxc`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/oxc/const-comparisons.html) |
| Biome | `nursery/noConstantComparisons` | yes | no | group nursery, since 2.6.6 | [docs](https://biomejs.dev/linter/rules/no-constant-comparisons/) |

## Code examples

### Incorrect: the rule reports this

```js
status_code <= 400 && status_code > 500;
status_code < 200 && status_code <= 299;
status_code > 500 && status_code >= 500;
a < a; // Always false
a >= a; // Always true
```

### Correct: the rule accepts this

```js
status_code >= 400 && status_code < 500;
500 <= status_code && 600 > status_code;
500 <= status_code && status_code <= 600;
a < b;
a <= b;
```

Examples from the Oxlint documentation.

## Enable it

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "oxc/const-comparisons": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noConstantComparisons": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Oxlint default](https://lintradar.dev/presets/oxlint-default.md) | Oxlint | `oxlint` | 111 | 50.8M | +183.6% |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |

## Related rules

- [oxc/bad-replace-all-arg](https://lintradar.dev/rules/oxc/bad-replace-all-arg.md): This rule warns when the `replaceAll` method is called with a regular expression that does not have the global flag (g).
- [oxc/erasing-op](https://lintradar.dev/rules/oxc/erasing-op.md): Checks for erasing operations, e.g., `x * 0`.
- [oxc/bad-object-literal-comparison](https://lintradar.dev/rules/oxc/bad-object-literal-comparison.md): Checks for comparisons between object and array literals.
- [oxc/missing-throw](https://lintradar.dev/rules/oxc/missing-throw.md): Checks whether the `throw` keyword is missing in front of a `new` expression.
- [oxc/bad-min-max-func](https://lintradar.dev/rules/oxc/bad-min-max-func.md): Checks whether the clamp function `Math.min(Math.max(x, y), z)` always evaluates to a constant result because the arguments are in the wrong order.
- [oxc/number-arg-out-of-range](https://lintradar.dev/rules/oxc/number-arg-out-of-range.md): Checks whether the radix or precision arguments of number-related functions exceed the limit.

---

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