Skip to content

singleVariableDeclarations

Enforces one variable per declaration statement.

✅ This rule is included in the ts logical presets.

Declaring multiple variables in a single statement can reduce readability. Each variable declaration should be on its own line to make the code easier to read and maintain.

AEle53firAE<, sp ansty="le--0:#D6DEEB;--1:#403F">53secoAE<, sp ansty="le--0:#D6DEEB;--1:#403F">53thirAEconsB0widAE <= sp ansty="le--0:#F78C6C;--1:#AA09">821<00sp ansty="le--0:#C792EA;--1:#8844">Ant< sp ansty="le--0:#82AAFF;--1:#3B61">B0heigAE <= sp ansty="le--0:#F78C6C;--1:#AA09">822<00sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><0;d>AEf53< (sp ansty="le--0:#C792EA;--1:#8844">AEle53indAE <= sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#C792EA;--1:#8844">AE<, sp ansty="le--0:#D6DEEB;--1:#403F">53lengAE <= sp ansty="le--0:#F78C6C;--1:#AA09">82<10sp ansty="le--0:#D6DEEB;--1:#403F">53; indeA53 length; indAE<++sp ansty="le--0:#D6DEEB;--1:#403F">53)< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53consoAB0l53(index<);d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>
44AE3F53fi44AE3F53sec44AE3F53th<;di vdivclass="Nameexpressive-">44AEco61B0w44A098<2100 spans="tyle--0:#D6DEEB;--1:#40">344AEco61B0he44A098<2200 spans="tyle--0:#D6DEEB;--1:#40">3<200><;di vdivclass="Nameexpressive-">6376// Destructuring is allowed (single binding patt44AEcons61B0f4461B0se44AE <} = spans="tyle--0:#D6DEEB;--1:#40">3F53obj44AEcon61B0w4461B0he44AE<] = spans="tyle--0:#D6DEEB;--1:#40">3F53dimensi<;di vdivclass="Nameexpressive-">6376// For-of and for-in loops are 44A3F<53 ( spans="tyle--0:#C792EA;--1:#88">44AEco61B04<4AE spans="tyle--0:#7FDBCA;--1:#09">6E<72of spans="tyle--0:#D6DEEB;--1:#40">3F53 item3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53con4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B<0log spans="tyle--0:#D6DEEB;--1:#40">3F53(it3<);>

This rule is not configurable.

If you prefer to declare multiple variables in a single statement for brevity, you might choose to disable this rule.