Skip to content

variableDeletions

Reports attempting to delete variables with the delete operator.

✅ This rule is included in the ts javascript presets.

The delete operator is only meant to remove properties from objects, not variables. Attempting to delete a variable in strict mode will cause a syntax error. In non-strict mode, it will silently fail and return false without actually deleting the variable, which can lead to confusing bugs.

AEle53couAE <= sp ansty="le--0:#F78C6C;--1:#AA09">8<25sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">72dele53 coundAEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0calcula1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53val7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb1<1)sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#7FDBCA;--1:#096E">72dele53 valu5<3}d ivclassNa="meco"><}d>
44AE3F53c44A0<9825 spans="tyle--0:#D6DEEB;--1:#40">33F53co4<4AE= spans="tyle--0:#D6DEEB;--1:#40">361B0undef3c44AEco61B<0obj spans="tyle--0:#C792EA;--1:#88">44AE = { proper0<9821 spans="tyle--0:#C792EA;--1:#88">4436E72de3F53< obj spans="tyle--0:#C792EA;--1:#88">4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72prop3

This rule is not configurable.

If your codebase relies on non-standard behavior that involves deleting variables (which is highly discouraged), you might choose to disable this rule. For example, if you target a legacy runtime with non-standard JavaScript semantics, standard practices may not apply to you.