oxc/double-comparisons Correctness
它的作用
此规则检查逻辑表达式中的重复比较。
这为什么不好?
冗余的比较可能会令人困惑,并使代码更难理解。
示例
此规则的错误代码示例:
javascript
x === y || x < y;
x < y || x === y;此规则的正确代码示例:
javascript
x <= y;
x >= y;如何使用
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版本
此规则在 v0.0.22 中添加。
