Skip to content
← Back to rules

oxc/erasing-op Correctness

✅ This rule is turned on by default.
⚠️ 🛠️ A dangerous auto-fix is available for this rule.

What it does ​

Checks for erasing operations, e.g., x * 0.

Based on https://rust-lang.github.io/rust-clippy/master/#/erasing_op

Why is this bad? ​

The whole expression can be replaced by zero. This is most likely not the intended outcome and should probably be corrected.

Examples ​

Examples of incorrect code for this rule:

javascript
let x = 1;
let y = x * 0;

Examples of correct code for this rule:

javascript
let x = 1;
let y = 0;

How to use ​

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

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

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

Version ​

This rule was added in v0.1.1.

References ​