Skip to content

oxc/erasing-op Correctness ​

✅ This rule is turned on by default.
💡 A suggestion 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.

Example ​

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 in the CLI or using the config file, you can use:

bash
oxlint --deny oxc/erasing-op
json
{
  "rules": {
    "oxc/erasing-op": "error"
  }
}

References ​

Released under the MIT License.