# oxc/erasing-op

> Disallow operations with `0` that erase the other operand

`x * 0`, `x & 0` and `0 / x` are zero for any ordinary number `x`. The other operand does nothing, so the `0` is probably a typo or a leftover from debugging.

The rule reports `*` and `&` with a literal `0` on either side, and `/` with a literal `0` on the left. Dividing by zero, as in `x / 0`, isn't reported.

`--fix-dangerously` replaces the whole expression with `0`. That drops the other operand, including any function call in it.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"oxc/erasing-op" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}
```js
const tax = price * 0;
const masked = flags & 0;
const ratio = 0 / total;
```

Not reported:

{/* good */}
```js
const tax = price * 0.2;
const masked = flags & 1;
const ratio = used / total;
```
