Skip to content
← Back to rules

oxc/double-comparisons 正しさ

This rule is turned on by default.
🛠️ An auto-fix is available for this rule.

何を検出するか

このルールは論理式内の重複比較をチェックします。

なぜ問題なのか

不要な比較は混乱を引き起こし、コードの理解を難しくします。

このルールに違反するコードの例:

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

このルールに準拠するコードの例:

javascript
x <= y;
x >= y;

使い方

設定ファイルまたは CLI でこのルールを有効化するには、次のように使用できます:

json
{
  "rules": {
    "oxc/double-comparisons": "error"
  }
}
bash
oxlint --deny oxc/double-comparisons

参照