Require expressions of type void to appear in statement position.
✅ This rule is included in the ts logical and logicalStrict presets.
The void type in TypeScript refers to a function return that is meant to be ignored.
Using a void-typed value—such as assigning the result of a called function to a variable or returning it from another function—is often a programmer error.
Even when used correctly, void expressions in value positions can be misleading for other developers.
This rule reports void expressions that are used in misleading locations such as being assigned to a variable, provided as a function argument, or returned from a function.
AEdecla5<3 sp ansty="le--0:#C792EA;--1:#8844">AEfuncti3 sp>5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53messa1(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:#7FDBCA;--1:#096E">71)sp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo3 sp>5<3;d ivclassNa="meec-li">AEconsB0resuAE <= sp ansty="le--0:#82AAFF;--1:#3B61">B0l= sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dhel1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp>3;d><);d ivclassNa="meco"><);d>);d>);d>AEdecla5<3 sp ansty="le--0:#C792EA;--1:#8844">AEfuncti3 sp>5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53messa1(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:#7FDBCA;--1:#096E">71)sp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo3 sp>5<3;d ivclassNa="meec-li">5<3[sp ansty="le--0:#F78C6C;--1:#AA09">83[sp><21sp ansty="le--0:#D6DEEB;--1:#403F">5321sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><22sp ansty="le--0:#D6DEEB;--1:#403F">5322sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><23sp ansty="le--0:#D6DEEB;--1:#403F">523sp><3]sp ansty="le--0:#C792EA;--1:#8844">A3]sp>B0forEa5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">51(sp><3nsp ansty="le--0:#D9F5DD;--1:#1111">13nsp><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">5=>sp><3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l3 sp>5<3(sp ansty="le--0:#82AAFF;--1:#3B61">B0Stri3(sp>53(n))3;d><);d ivclassNa="meco"> log(String(n))"><);d>);d>);d>AEdecla5<3 sp ansty="le--0:#C792EA;--1:#8844">AEfuncti3 sp>5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53messa1(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:#7FDBCA;--1:#096E">71)sp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo3 sp>5<3;d ivclassNa="meec-li">AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0r3 sp>11<()sp ansty="le--0:#D6DEEB;--1:#403F">53()sp>3;d>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l3 sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Ddo1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp> {d><);d ivclassNa="meec-li">5);d><3}d ivclassNa="meco"><}d>}d>3}d> 44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">10log><111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes111(>6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6111)>361B0361B<0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dh111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name">53)><;di vdivclass="Nameexpressive-">44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">10log><111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes111(>6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6111)>361B0330<9821 spans="tyle--0:#D6DEEB;--1:#40">3F9821><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9822 spans="tyle--0:#D6DEEB;--1:#40">3F9822><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9823 spans="tyle--0:#D6DEEB;--1:#40">39823>4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0for4AE.>31<111( spans="tyle--0:#D7DBE0;--1:#40">3111(>1<111) spans="tyle--0:#D6DEEB;--1:#40">3111)>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">de61B<0log spans="tyle--0:#D6DEEB;--1:#40">30log>61B0St3F53(53 >3F5<3}) ;divclass="Name"> { log(String(n));"><})>})>3})>;di><;di vdivclass="Nameexpressive-">44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">10log><111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes111(>6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6111)>361B0344AEfunc361B<0run spans="tyle--0:#D9F5DD;--1:#11">110run><11() spans="tyle--0:#D6DEEB;--1:#40">3F11()><53 {divclass="Nameec-">de61B<0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111">53 ><53) ;divclass="Nameec-">353)><);>);>;di><}di vdivclass="Nameexpressive-">44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">10log><111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes111(>6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6111)>361B034848344361B<0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dmes111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name">53)>}di><;di vdivclass="Nameexpressive-">44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">10log><111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes111(>6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6111)>361B036E72361B<0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dexplicitly ign111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name">53)>;di>
This rule is not configurable.
If you frequently use concise arrow function shorthands that return void, or if your codebase intentionally uses void expressions as values in certain patterns, you may not need this rule.
The return type of a function can be inspected by going to its definition or hovering over it in an IDE, so some teams prefer relying on IDE hints rather than lint rules for this purpose.