Skip to content

parameterReassignments

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">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">B0stri1<1)sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53valuA53 valAB0tr53(<);d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu53 valu5<3}d ivclassNa="meco"><}d>AEconsB0AE <= sp ansty="le--0:#D9F5DD;--1:#1111">1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53cou7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0numb1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#D6DEEB;--1:#403F">53couAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53couAE <+ sp ansty="le--0:#F78C6C;--1:#AA09">8<21sp ansty="le--0:#C792EA;--1:#8844">AAE< sp ansty="le--0:#C792EA;--1:#8844">AEretur53couAA5<3;d ivclassNa="meco"><};d>
44AEfunc361B0pro1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v6361B0st1<111) spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de44AEco61B0tri44A3F53v4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B03F5<3() ;divclass="Nameec-">de44AEre3F53 trim3<}di vdivclass="Nameexpressive-">44AEco6144A1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53c64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu1<111) spans="tyle--0:#C792EA;--1:#88">44AE <=> {divclass="Nameec-">4444AEco61B0increme44A3F53c44A0<9821 spans="tyle--0:#C792EA;--1:#88">4 ><4AE ;divclass="Nameec-">4444AEret3F53increme4<4AE ;divclass="Nameec-">4<4AE} spans="tyle--0:#D6DEEB;--1:#40">3<;}>

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.