Reports reassigning variables declared with function declarations.
✅ This rule is included in the ts javascript presets.
Reassigning a function declaration can make code harder to understand and maintain.
Function declarations are hoisted to the top of their scope, and reassigning them can lead to unexpected behavior.
AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0calcula3 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">B0numb3 sp>1<1)sp ansty="le--0:#7FDBCA;--1:#096E">71)sp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb3 sp>53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>53 valuA5<3 sp ansty="le--0:#F78C6C;--1:#AA09">83 sp><22sp ansty="le--0:#D6DEEB;--1:#403F">522sp> {d><3;d ivclassNa="meec-li">53;d><3}d ivclassNa="meec-li">d3}d>B0calcula5<3 sp ansty="le--0:#C792EA;--1:#8844">A3 sp>5<3 sp ansty="le--0:#D9F5DD;--1:#1111">13 sp><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">B0numb3 sp>1<1)sp ansty="le--0:#D6DEEB;--1:#403F">51)sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53 valu=>sp>A5<3 sp ansty="le--0:#F78C6C;--1:#AA09">83 sp><23sp ansty="le--0:#D6DEEB;--1:#403F">523sp><3;d ivclassNa="meco"> value * "><3;d>3;d>3;d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0processDa3 sp>11<()sp ansty="le--0:#7FDBCA;--1:#096E">7()sp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo3 sp>53< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4DProcessing.1"sp><..sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp> {d><);d ivclassNa="meec-li">5);d><3}d ivclassNa="meec-li">d3}d>53processDatA5<3 sp ansty="le--0:#FF6A83;--1:#A248">48nu3 sp>5<3;d ivclassNa="meco">3;d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0getVal3 sp>11<()sp ansty="le--0:#7FDBCA;--1:#096E">7()sp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb3 sp>53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>5<3 sp ansty="le--0:#F78C6C;--1:#AA09">823 sp><42sp ansty="le--0:#D6DEEB;--1:#403F">542sp> {d><3;d ivclassNa="meec-li">53;d><3}d ivclassNa="meec-li">d3}d>53getValAE<++sp ansty="le--0:#D6DEEB;--1:#403F">5++sp><3;d ivclassNa="meco"><+;d>+;d>3;d> 44AEfunc361B0calcu1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v111(>6361B0nu1<111) spans="tyle--0:#7FDBCA;--1:#09">6111)>361B0nu3F<53 {divclass="Nameec-">de44AEre3F53 va4<4AE* spans="tyle--0:#D6DEEB;--1:#40">34AE*>0<9822 spans="tyle--0:#D6DEEB;--1:#40">39822>53 >3c44AEco61B0re44A61B0calcu309<8210 spans="tyle--0:#D6DEEB;--1:#40">3F8210><53) ;divclass="Name"><10)>10)>53)><;di vdivclass="Nameexpressive-">44AEco61B0process44AE = funct11<11() spans="tyle--0:#7FDBCA;--1:#09">611()>4<4AE spans="tyle--0:#C5E478;--1:#3B">61B04AE >44de3F53con4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DProcessin111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">4<4AE ;divclass="Nameec-">4<4AE} spans="tyle--0:#D6DEEB;--1:#40">34AE}>4AE>c61B0process34<4AE= spans="tyle--0:#D6DEEB;--1:#40">34AE=>11<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53con53 >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DDifferent proces111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111">53 ><53) ;divclass="Nameec-">3F53)><53} ;divclass="Name"> { console.log("Different processing")"><;}>;}>53}>;di><;di vdivclass="Nameexpressive-">44AE61B0getV44A11<11() spans="tyle--0:#7FDBCA;--1:#09">611()>4<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu4AE >44AE <=> {divclass="Nameec-">4444AEret09<8242 spans="tyle--0:#C792EA;--1:#88">48242>=> ><4AE ;divclass="Nameec-">4<4AE} spans="tyle--0:#D6DEEB;--1:#40">34AE}>4AE>c61B0getV34<4AE= spans="tyle--0:#D6DEEB;--1:#40">34AE=>11<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3>098<2100 spans="tyle--0:#D6DEEB;--1:#40">32100> { return 42;};getValue = () => "><100>100>;di>
This rule is not configurable.
If you’re working in an existing codebase where reassigning function declarations is a common pattern and refactoring would be too costly, you might choose to disable this rule.
However, using function expressions or const variables is generally a better practice when reassignment is needed.