Skip to content
← Back to rules

oxc/bad-comparison-sequence Correctness

This rule is turned on by default.

무엇을 하나요

This rule applies when the comparison operator is applied two or more times in a row.

왜 문제인가요?

Because comparison operator is a binary operator, it is impossible to compare three or more operands at once. If comparison operator is used to compare three or more operands, only the first two operands are compared and the rest is compared with its result of boolean type.

예시

이 규칙에서 올바르지 않은 코드 예:

javascript
if ((a == b) == c) {
  console.log("a, b, and c are the same");
}

이 규칙에서 올바른 코드 예:

javascript
if (a == b && b == c) {
  console.log("a, b, and c are the same");
}

사용 방법

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

json
{
  "rules": {
    "oxc/bad-comparison-sequence": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "oxc/bad-comparison-sequence": "error",
  },
});
bash
oxlint --deny oxc/bad-comparison-sequence

버전

이 규칙은 v0.0.3에 추가되었습니다.

참고