Skip to content

chainedAssignments

Reports using chained assignment expressions (e.g., a = b = c).

✅ This rule is included in the ts stylistic and stylisticStrict presets.

Chained assignments can be hard to read and can lead to unexpected behavior with variable scoping and type inference. Each assignment creates a reference to the same value, which may cause confusion when dealing with mutable values.

AEle53firsAEle53secon53firsA53 seconA5<3 sp ansty="le--0:#F78C6C;--1:#AA09">8<21sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><1;d>AEle53firsAEle53seconAEle53thir53firsA53 seconA53 thirA5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0getVal53(<);d ivclassNa="meco"><);d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0proce1<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:#7FDBCA;--1:#096E">7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEle53resulnt< sp ansty="le--0:#C792EA;--1:#8844">AEle53cach53< sp ansty="le--0:#D6DEEB;--1:#403F">53resulA53 cachA53 valuA5<3 sp ansty="le--0:#F78C6C;--1:#AA09">8<22sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>
44AE3F53fi44AE3F53sec3F53fi4<4AE= spans="tyle--0:#D6DEEB;--1:#40">30<9821 spans="tyle--0:#D6DEEB;--1:#40">33F53sec4<4AE= spans="tyle--0:#D6DEEB;--1:#40">30<9821 spans="tyle--0:#D6DEEB;--1:#40">3<= 1><;di vdivclass="Nameexpressive-">44AE3F53fi44AE3F53sec44AE3F53th44AEco61B0v44A61B0getV3F5<3() ;divclass="Nameec-">3F53fi4<4AE= spans="tyle--0:#D6DEEB;--1:#40">3F53 va3F53sec4<4AE= spans="tyle--0:#D6DEEB;--1:#40">3F53 va3F53th4<4AE= spans="tyle--0:#D6DEEB;--1:#40">3F53 va<;di vdivclass="Nameexpressive-">44AEfunc361B0pro1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v6361B0nu1<111) spans="tyle--0:#7FDBCA;--1:#09">6361B03F<53 {divclass="Nameec-">de44AE3F53resde44AE3F53cade44AEco61B0comp44A3F53v44A0<9822 spans="tyle--0:#D6DEEB;--1:#40">33F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53res4<4AE= spans="tyle--0:#D6DEEB;--1:#40">3F53 compu3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53ca4<4AE= spans="tyle--0:#D6DEEB;--1:#40">3F53 compu3

This rule is not configurable.

If your codebase frequently uses chained assignments as a concise idiom and you find them readable, you might choose to disable this rule. However, breaking chained assignments into separate statements generally improves code clarity and reduces potential for bugs.