Reports using assignment expressions in return statements.
✅ This rule is included in the ts stylistic and stylisticStrict presets.
Using assignments in return statements can make code harder to read and can lead to confusion about whether the assignment or the returned value is the primary intent.
Assignment expressions return the assigned value, but mixing assignment with return makes the control flow less clear.
AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0getVal3 sp>11<()sp ansty="le--0:#D6DEEB;--1:#403F">53()sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEle sp>53valu {d>nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>53 (valuA5<3 sp ansty="le--0:#F78C6C;--1:#AA09">83 sp><21sp ansty="le--0:#D6DEEB;--1:#403F">5321sp><);d ivclassNa="meec-li">5);d><3}d ivclassNa="meco"><}d>}d>3}d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0proce3 sp>11<()sp ansty="le--0:#D6DEEB;--1:#403F">53()sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEle sp>53resul {d>nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>53 (resulA5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0calcula3 sp>53()<);d ivclassNa="meec-li">5);d><3}d ivclassNa="meco"><}d>}d>3}d>AEconsB0arrAE <= sp ansty="le--0:#D9F5DD;--1:#1111">11= sp><()sp ansty="le--0:#C792EA;--1:#8844">AE =()sp><> sp ansty="le--0:#D6DEEB;--1:#403F">53(val> sp>AE <= sp ansty="le--0:#F78C6C;--1:#AA09">82= sp><42sp ansty="le--0:#D6DEEB;--1:#403F">5342sp><);d ivclassNa="meco"> (value = 42"><);d>);d>);d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0compou3 sp>11<()sp ansty="le--0:#D6DEEB;--1:#403F">53()sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEle sp>53coun {d>nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>53 (counAE<+=sp ansty="le--0:#D6DEEB;--1:#403F">5+=sp><3 sp ansty="le--0:#F78C6C;--1:#AA09">83 sp><25sp ansty="le--0:#D6DEEB;--1:#403F">5325sp><);d ivclassNa="meec-li">5);d><3}d ivclassNa="meco"><}d>}d>3}d> 44AEfunc361B0getV11<11() spans="tyle--0:#D6DEEB;--1:#40">3F11()><53 {divclass="Nameec-">de44AE3F53v44A0<9821 spans="tyle--0:#D6DEEB;--1:#40">39821>53 >de44AEre3F53 va3<}di vdivclass="Nameexpressive-">44AEfunc361B0pro11<11() spans="tyle--0:#D6DEEB;--1:#40">3F11()><53 {divclass="Nameec-">de44AE3F53re44A61B0calcu3F553 ><3() ;divclass="Nameec-">de44AEre3F53 res3()>3}di><}di vdivclass="Nameexpressive-">44AEco61B0a44A11<11() spans="tyle--0:#C792EA;--1:#88">44AE 11()><=> {divclass="Nameec-">4444AEco61B0v44A09<8242 spans="tyle--0:#C792EA;--1:#88">48242>=> ><4AE ;divclass="Nameec-">4444AEret3F53v44AE><4AE ;divclass="Nameec-">4<4AE} spans="tyle--0:#D6DEEB;--1:#40">34AE}>4AE> { const value = 42; return value"><;}>;}>}di><;di vdivclass="Nameexpressive-">44AEfunc361B0comp11<11() spans="tyle--0:#D6DEEB;--1:#40">3F11()><53 {divclass="Nameec-">de44AE3F53c44A0<9820 spans="tyle--0:#D6DEEB;--1:#40">39820>53 >3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53co53 >4430<9825 spans="tyle--0:#D6DEEB;--1:#40">39825>de44AEre3F53 co3;di>
This rule is not configurable.
If your codebase uses assignments in return statements as a common idiom and you find them readable, you might choose to disable this rule.
However, separating assignments from return statements generally improves code clarity and reduces potential for confusion.