Skip to content

defaultParameterLast

Enforce default parameters to be last.

✅ This rule is included in the ts javascript presets.

Putting default parameters last allows function calls to omit optional tail arguments. When default parameters appear before required ones, callers must explicitly pass undefined to skip them.

This rule reports parameters with default values or optional markers (?) that appear before required parameters.

AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0gre1<1(sp ansty="le--1:#403F"><53sp ansty="le--0:#D7DB">E0naEA5<3 sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4DWor1<1"sp ansty="le--1:#403F"><53sp ansty="le--0:#D6DE">EB<, sp ansty="le--0:#D7DB">E0greeti7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri1<1)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:#D6DEEB;--1:#403F">5<3`sp ansty="le--0:#E2817F;--1:#B238">34<${sp ansty="le--0:#D6DEEB;--1:#403F">53greeti3<4}sp ansty="le--0:#ECC48D;--1:#3B61">B0<, sp ansty="le--0:#E2817F;--1:#B238">34<${sp ansty="le--0:#D6DEEB;--1:#403F">53na3<4}sp ansty="le--0:#ECC48D;--1:#3B61">B<0!sp ansty="le--0:#D6DEEB;--1:#403F">5<3`sp ansty="le--0:#D6DEEB;--1:#403F">53<);d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0calcula1<1(sp ansty="le--1:#403F"><53sp ansty="le--0:#D7DB">E<0asp ansty="le--0:#D6DE">EA5<3 sp ansty="le--0:#F78C6C;--1:#AA09">8<21sp ansty="le--1:#403F"><53sp ansty="le--0:#D6DE">EB<, sp ansty="le--0:#D7DB">E<0bsp ansty="le--0:#7FDBCA;--1:#096E">7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb<53sp ansty="le--0:#D6DE">EB<, sp ansty="le--0:#D7DB">E<0csp ansty="le--0:#D6DE">EA5<3 sp ansty="le--0:#F78C6C;--1:#AA09">8<22sp ansty="le--0:#D9F5DD;--1:#1111">1<1)sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu53 A53 A53 5<3}d ivclassNa="meco"><}d>AEconsB0AE <= sp ansty="le--0:#D9F5DD;--1:#1111">1<1(sp ansty="le--0:#D7DBE0;--1:#403F">5<3xsp ansty="le--0:#C792EA;--1:#8844">AE <= sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#C792EA;--1:#8844">AE<, sp ansty="le--0:#D7DBE0;--1:#403F">5<3ysp ansty="le--0:#7FDBCA;--1:#096E">7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0numb1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =<> sp ansty="le--0:#D6DEEB;--1:#403F">5 sp><3xsp ansty="le--0:#C792EA;--1:#8844">AE <+ sp ansty="le--0:#D6DEEB;--1:#403F">53AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0examp1<1(sp ansty="le--0:#D7DBE0;--1:#403F">5<3asp ansty="le--0:#7FDBCA;--1:#096E">725<3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb<53sp ansty="le--0:#D6DE">EB<, sp ansty="le--0:#D7DB">E<0bsp ansty="le--0:#7FDBCA;--1:#096E">7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb1<1)sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu53 (AE5<3 sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#D6DEEB;--1:#403F">53<) sp ansty="le--0:#C792EA;--1:#8844">A53 5<3}d ivclassNa="meco"><}d>
44AEfunc361B0g1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53gree6361B0st<3F53 spans="tyle--0:#D6">DEDBE0D4<4AE= spans="tyle--0:#D6DEEB;--1:#40">31<111" spans="tyle--0:#ECC48D;--1:#98">4E4DW1<111" spans="tyle--0:#D9F5DD;--1:#11">1<111) spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53con4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B<0log spans="tyle--0:#D6DEEB;--1:#40">3338<34${ spans="tyle--0:#D6DEEB;--1:#40">3F53gree3<834} spans="tyle--0:#ECC48D;--1:#3B">6138<34${ spans="tyle--0:#D6DEEB;--1:#40">3F533<834} spans="tyle--0:#ECC48D;--1:#3B">6<1B0! spans="tyle--0:#D6DEEB;--1:#40">33F<53) ;divclass="Nameec-">3<);><}di vdivclass="Nameexpressive-">44AEfunc361B0calcu1<111( spans="tyle--0:#D7DBE0;--1:#40">36361B0nu<3F53 spans="tyle--0:#D6">DEDD4<4AE= spans="tyle--0:#D6DEEB;--1:#40">30<9821 spans="tyle--1:#40"><3F53 spans="tyle--0:#D6">DEDD4<4AE= spans="tyle--0:#D6DEEB;--1:#40">30<9822 spans="tyle--0:#D9F5DD;--1:#11">1<111) spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de44AEre3F5<3 a spans="tyle--0:#C792EA;--1:#88">4<4AE+ spans="tyle--0:#D6DEEB;--1:#40">3F5<3 b spans="tyle--0:#C792EA;--1:#88">4<4AE+ spans="tyle--0:#D6DEEB;--1:#40">3F5<3 c ;divclass="Nameec-">3<}di vdivclass="Nameexpressive-">44AEco6144A1<111( spans="tyle--0:#D7DBE0;--1:#40">364<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu44344A0<9820 spans="tyle--0:#D9F5DD;--1:#11">1<111) spans="tyle--0:#C792EA;--1:#88">44AE< => spans="tyle--0:#D6DEEB;--1:#40">3 >44A3F<53y ;divclass="Name"><+ y><;di vdivclass="Nameexpressive-">44AEfunc361B0exa1<111( spans="tyle--1:#40"><3F53 spans="tyle--0:#D7">DD4<4AE= spans="tyle--0:#D6DEEB;--1:#40">30<9821 spans="tyle--0:#D6DEEB;--1:#40">3F<53, spans="tyle--0:#7FDBCA;--1:#09">6E7<2... spans="tyle--0:#D7DBE0;--1:#40">3F536361B0nu3F<53[] spans="tyle--0:#D9F5DD;--1:#11">1<111) spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de44AEre3F53 4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0re31<111( spans="tyle--1:#40"><3F53 spans="tyle--0:#D7">DBE<0sum spans="tyle--0:#D6">DEDBE0v1<111) spans="tyle--0:#D6DEEB;--1:#40">344 spans="tyle--0:#D6DEEB;--1:#40">3F53 >4<4AE+ spans="tyle--0:#D6DEEB;--1:#40">3F53 v6<67B, spans="tyle--0:#D6DEEB;--1:#40">3F53< a) ;divclass="Nameec-">3<);>

This rule is not configurable.

If your API design intentionally places default parameters before required ones for readability or documentation purposes, you may disable this rule. Some legacy APIs may also have established parameter orderings that cannot be changed without breaking changes.