Skip to content
← Back to rules

oxc/misrefactored-assign-op Suspicious

💡 A suggestion is available for this rule.

它的作用

https://rust-lang.github.io/rust-clippy/master/#/misrefactored_assign_op

检查 a op= a op ba op= b op a 模式。

为什么这不好?

这些很可能是错误,原本想写的是 a op= b

示例

以下是此规则的不正确代码示例:

javascript
a += a + b;
a -= a - b;

以下是此规则的正确代码示例:

javascript
a += b;
a -= b;

如何使用

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

json
{
  "rules": {
    "oxc/misrefactored-assign-op": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "oxc/misrefactored-assign-op": "error",
  },
});
bash
oxlint --deny oxc/misrefactored-assign-op

版本

此规则是在 v0.1.1 中添加的。

参考资料