Skip to content

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.

const
const value: number
value
=
const x: any
x
* 0;
const
const value: number
value
= 0 *
const x: any
x
;
const
const value: number
value
=
const x: any
x
& 0;
const
const value: number
value
= 0 /
const x: any
x
;

This rule is not configurable.

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.

Made with ❤️‍🔥 around the world by the Flint team and contributors.