Disallow reassignment of function parameters.
✅ This rule is included in the ts logical presets.
Reassigning function parameters can make code harder to understand and debug.
The parameter’s original value becomes lost, making it difficult to trace what value the parameter had at different points in the function.
Using a new variable instead makes the intent clearer and preserves the original parameter value.
AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0proce3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53val1(sp>7<2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri3 sp>1<1)sp ansty="le--0:#D6DEEB;--1:#403F">531)sp>< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53valu sp>A53 valAB0tr53( {d><);d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>53 valu);d>5<3}d ivclassNa="meco"><}d>}d>3}d>AEconsB0AE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">53cou1(sp>7<2:sp ansty="le--0:#C792EA;--1:#8844">A2:sp>B0numb1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =>1)sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#D6DEEB;--1:#403F">53cou sp>AE <= sp ansty="le--0:#D6DEEB;--1:#403F">53cou= sp>AE <+ sp ansty="le--0:#F78C6C;--1:#AA09">8+ sp><21sp ansty="le--0:#C792EA;--1:#8844">A21sp> {d>AE< sp ansty="le--0:#C792EA;--1:#8844">AEretur sp>53couAA5<3;d ivclassNa="meco"> { count = count + 1; return count;"><};d>};d>3;d> 44AEfunc361B0pro1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v111(>6361B0st1<111) spans="tyle--0:#D6DEEB;--1:#40">3F111)><53 {divclass="Nameec-">de44AEco61B0tri44A3F53v4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B04AE.>3F553 ><3() ;divclass="Nameec-">de44AEre3F53 trim3()>3<}di vdivclass="Nameexpressive-">44AEco6144A1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53c111(>64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu4AE >1<111) spans="tyle--0:#C792EA;--1:#88">44AE 111)><=> {divclass="Nameec-">4444AEco61B0increme44A3F53c44A0<9821 spans="tyle--0:#C792EA;--1:#88">49821>=> ><4AE ;divclass="Nameec-">4444AEret3F53increme44AE><4AE ;divclass="Nameec-">4<4AE} spans="tyle--0:#D6DEEB;--1:#40">34AE}>4AE> { const incremented = count + 1; return incremented"><;}>;}>}di>
This rule is not configurable.
If your codebase intentionally reuses parameter variables for intermediate calculations, this rule might no be for you.
For example, if you prefer writing very small functions and feel confident you and any fellow developers won’t misunderstand the code, you might prefer to disable this rule.