Appearance
禁止两边完全相同的比较操作
将一个变量与自身进行比较通常是错误的,可能是拼写错误或重构失误。 这会令读者感到困惑,并可能引入运行时错误。
此规则的错误代码示例:
var x = 10; if (x === x) { x = 20; }
通过配置文件或 CLI 启用此规则,可以使用:
{ "rules": { "no-self-compare": "error" } }
oxlint --deny no-self-compare