numericErasingOperations
Reports operations that always result in zero, such as multiplication by zero.
✅ This rule is included in the ts logicalStrict presets.
This rule reports operations that always result in zero, regardless of the other operand.
These “erasing” operations typically indicate a logic error where the developer may have intended a different operation.
The entire expression can be replaced with 0 directly.
Examples
Section titled “Examples”const value = x * 0;const value = 0 * x;const value = x & 0;const value = 0 / x;const value = 0;const value = x * 1;const value = x & mask;const value = x / divisor;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you are intentionally using these operations for their side effects or as a stylistic choice to indicate the result should be zero, you may want to disable this rule.
However, in most cases, directly using 0 is clearer.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Oxlint:
oxc/erasing-op
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.