Skip to content

misleadingVoidExpressions

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">AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53messa7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri1<1)sp ansty="le--0:#7FDBCA;--1:#096E">7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo5<3;d ivclassNa="meec-li">AEconsB0resuAE <= sp ansty="le--0:#82AAFF;--1:#3B61">B0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dhel1<1"sp ansty="le--0:#D6DEEB;--1:#403F">53<);d ivclassNa="meco"><);d>AEdecla5<3 sp ansty="le--0:#C792EA;--1:#8844">AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53messa7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri1<1)sp ansty="le--0:#7FDBCA;--1:#096E">7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo5<3;d ivclassNa="meec-li">5<3[sp ansty="le--0:#F78C6C;--1:#AA09">8<21sp ansty="le--0:#D6DEEB;--1:#403F">53<, sp ansty="le--0:#F78C6C;--1:#AA09">8<22sp ansty="le--0:#D6DEEB;--1:#403F">53<, sp ansty="le--0:#F78C6C;--1:#AA09">8<23sp ansty="le--0:#D6DEEB;--1:#403F">5<3]sp ansty="le--0:#C792EA;--1:#8844">AB0forEa5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1(sp ansty="le--0:#D7DBE0;--1:#403F">5<3nsp ansty="le--0:#D9F5DD;--1:#1111">1<1)sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C792EA;--1:#8844">AE<=>sp ansty="le--0:#D6DEEB;--1:#403F">5sp><3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l5<3(sp ansty="le--0:#82AAFF;--1:#3B61">B0Stri53(n))<);d ivclassNa="meco"><);d>AEdecla5<3 sp ansty="le--0:#C792EA;--1:#8844">AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0l1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53messa7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri1<1)sp ansty="le--0:#7FDBCA;--1:#096E">7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo5<3;d ivclassNa="meec-li">AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0r11<()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:#82AAFF;--1:#3B61">B0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Ddo1<1"sp ansty="le--0:#D6DEEB;--1:#403F">53<);d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>
44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6361B0361B<0log spans="tyle--0:#D6DEEB;--1:#40">31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dh1<111" spans="tyle--0:#D6DEEB;--1:#40">3F<53) ;divclass="Name"><;di vdivclass="Nameexpressive-">44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6361B0330<9821 spans="tyle--0:#D6DEEB;--1:#40">3F<53, spans="tyle--0:#F78C6C;--1:#AA">0<9822 spans="tyle--0:#D6DEEB;--1:#40">3F<53, spans="tyle--0:#F78C6C;--1:#AA">0<9823 spans="tyle--0:#D6DEEB;--1:#40">34<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0for31<111( spans="tyle--0:#D7DBE0;--1:#40">31<111) spans="tyle--0:#D6DEEB;--1:#40">344 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">de61B<0log spans="tyle--0:#D6DEEB;--1:#40">361B0St3F53(3F5<3}) ;divclass="Name"><})><;di vdivclass="Nameexpressive-">44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6361B0344AEfunc361B<0run spans="tyle--0:#D9F5DD;--1:#11">11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de61B<0log spans="tyle--0:#D6DEEB;--1:#40">31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D1<111" spans="tyle--0:#D6DEEB;--1:#40">3F<53) ;divclass="Nameec-">3<);><}di vdivclass="Nameexpressive-">44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6361B034848344361B<0log spans="tyle--0:#D6DEEB;--1:#40">31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dmes1<111" spans="tyle--0:#D6DEEB;--1:#40">3F<53) ;divclass="Name"><;di vdivclass="Nameexpressive-">44AEdec344AEfunc361B<0log spans="tyle--0:#D9F5DD;--1:#11">1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6361B036E72361B<0log spans="tyle--0:#D6DEEB;--1:#40">31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dexplicitly ign1<111" spans="tyle--0:#D6DEEB;--1:#40">3F<53) ;divclass="Name">

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.