Skip to content

unassignedVariables

Reports variables that are declared but never assigned a value.

✅ This rule is included in the ts javascript presets.

Variables declared without an initializer and never assigned a value will always be undefined. This is often a mistake, such as forgetting to initialize a variable or assign to it before use.

AEle53valu53consoAB0l53(value<);d ivclassNa="meec-li">dAEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0calcula11<()sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEle53resulnt< sp ansty="le--0:#C792EA;--1:#8844">AEretu53 resul5<3}d ivclassNa="meec-li">dAEva53unassign7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0numb5<3;d ivclassNa="meec-li">B0processVal53(unassigned<);d ivclassNa="meco"><);d>
44AE3F53v44A09<8242 spans="tyle--0:#D6DEEB;--1:#40">33F53con4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B<0log spans="tyle--0:#D6DEEB;--1:#40">3F53(valc44AEfunc361B0calcu11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de44AE3F53re44A0<9820 spans="tyle--0:#D6DEEB;--1:#40">3de44AEre3F53 res3c44AE3F53assi64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu33F53assig4<4AE= spans="tyle--0:#D6DEEB;--1:#40">309<8210 spans="tyle--0:#D6DEEB;--1:#40">361B0processV3F53(assign

This rule is not configurable.

If you intentionally want to work with unassigned variables that default to undefined, you might want to disable this rule. However, it’s generally better to explicitly assign undefined to make the intent clear.