Skip to content

generatorFunctionYields

Reports generator functions that do not yield values.

✅ This rule is included in the ts logical presets.

Generator functions use the function* syntax to create iterators that can produce multiple values over time. Without a yield expression, the generator will not produce any values and behaves like an empty iterator. This is likely unintentional and indicates incomplete implementation or a misunderstanding of generator functions.

AEfunctio5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0emptyGenerat11<()sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53consoAB0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4DNo yield he1<1"sp ansty="le--0:#D6DEEB;--1:#403F">53<);d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>AEfunctio5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0generatorThatRetur11<()sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu5<3 sp ansty="le--0:#F78C6C;--1:#AA09">82<42sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>AEcla5<3 sp ansty="le--0:#FFCB8B;--1:#1111">11Collecti53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AB0iterat11<()sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt < sp ansty="le--0:#7FDBCA;--1:#096E">72thAB0proce53(<);d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">5<3}d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>
44AEfunct361B0num11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de44AEy30<9821 spans="tyle--0:#D6DEEB;--1:#40">3de44AEy30<9822 spans="tyle--0:#D6DEEB;--1:#40">3de44AEy30<9823 spans="tyle--0:#D6DEEB;--1:#40">33<3;><}di vdivclass="Nameexpressive-">44AEfunct361B0r1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53s6361B0nu<3F53 spans="tyle--0:#D6">DEDBE<0end spans="tyle--0:#7FDBCA;--1:#09">6361B0nu1<111) spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de44A3F<53 ( spans="tyle--0:#C792EA;--1:#88">44AE344A3F53start<; i spans="tyle--0:#C792EA;--1:#88">4<4AE< spans="tyle--0:#D6DEEB;--1:#40">3F53 en443F5<3) {divclass="Nameec-">dent< spans="tyle--0:#C792EA;--1:#88">44AEy3F5<3 i ;divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">33< }><}di vdivclass="Nameexpressive-">44AEc31111Collec3F<53 {divclass="Nameec-">de4<4AE* spans="tyle--0:#82AAFF;--1:#3B">61B0iter11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">dent< spans="tyle--0:#C792EA;--1:#88">44AEyi36E724<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72i33F<53 spans="tyle--0:#D6DEEB;--1:#40">33< }>

This rule is not configurable.

If you intentionally want to create generator functions that produce no values (empty iterators), you can disable this rule. However, in most cases, such functions should not be generators.