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.

AEconsB0valAE <= sp ansty="le--0:#D6DEEB;--1:#403F">5<3xsp ansty="le--0:#C792EA;--1:#8844">AE <* sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><0;d>AEconsB0valAE <= sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#C792EA;--1:#8844">AE <* sp ansty="le--0:#D6DEEB;--1:#403F">53AEconsB0valAE <= sp ansty="le--0:#D6DEEB;--1:#403F">5<3xsp ansty="le--0:#C792EA;--1:#8844">AE <& sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><0;d>AEconsB0valAE <= sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#C792EA;--1:#8844">AE 53
44AEco61B0v44A0<9820 spans="tyle--0:#D6DEEB;--1:#40">3<= 0><;di vdivclass="Nameexpressive-">44AEco61B0v44A344A0<9821 spans="tyle--0:#D6DEEB;--1:#40">3<* 1><;di vdivclass="Nameexpressive-">44AEco61B0v44A344A3F53m<;di vdivclass="Nameexpressive-">44AEco61B0v44A344A3F53divi

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.