Skip to content
← Back to rules

oxc/double-comparisons Correctness

✅ This rule is turned on by default.
💡 A suggestion is available for this rule.

What it does ​

This rule checks for double comparisons in logical expressions.

Why is this bad? ​

Redundant comparisons can be confusing and make code harder to understand.

Examples ​

Examples of incorrect code for this rule:

javascript
x === y || x < y;
x < y || x === y;

Examples of correct code for this rule:

javascript
x <= y;
x >= y;

How to use ​

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "oxc/double-comparisons": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "oxc/double-comparisons": "error",
  },
});
bash
oxlint --deny oxc/double-comparisons

Version ​

This rule was added in v0.0.22.

References ​