Reports switch statements where the default clause is not last.
✅ This rule is included in the ts logical and logicalStrict presets.
When a default clause appears before other case clauses in a switch statement, it can lead to confusion about the control flow.
While the default clause will still only execute when no other case matches, placing it in the middle or at the beginning makes the code harder to understand.
Convention and readability are improved by keeping the default clause at the end of switch statements.
AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0getDescripti3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53val1(sp>7<2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb3 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">B0stri3 sp>53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEswit sp>53 (value) {d>< {d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEdefau sp>5 {d><3:d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>5<3 sp ansty="le--0:#D9F5DD;--1:#1111">13 sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dunkno1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp>3:d><3;d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEca sp>5<3 sp ansty="le--0:#F78C6C;--1:#AA09">83 sp><21sp ansty="le--0:#D6DEEB;--1:#403F">521sp>3;d><3:d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>5<3 sp ansty="le--0:#D9F5DD;--1:#1111">13 sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Do1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp>3:d><3;d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEca sp>5<3 sp ansty="le--0:#F78C6C;--1:#AA09">83 sp><22sp ansty="le--0:#D6DEEB;--1:#403F">522sp>3;d><3:d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>5<3 sp ansty="le--0:#D9F5DD;--1:#1111">13 sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dt1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp>3:d><3;d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">5 sp>3;d><3}d ivclassNa="meec-li">53}d><3}d ivclassNa="meec-li">d3}d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0processVal3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53inp1(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>53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEswit sp>53 (input) {d>< {d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEca sp>5<3 sp ansty="le--0:#D9F5DD;--1:#1111">13 sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dsta1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp> {d><3:d ivclassNa="meec-li">53 < sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4DStarting.1"sp><..sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp>3:d><);d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEbre sp>5);d><3;d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEdefau sp>53;d><3:d ivclassNa="meec-li">53 < sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4DProcessing.1"sp><..sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp>3:d><);d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEbre sp>5);d><3;d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEca sp>5<3 sp ansty="le--0:#D9F5DD;--1:#1111">13 sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4De1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp>3;d><3:d ivclassNa="meec-li">53 < sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4DEnding.1"sp><..sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp>3:d><);d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEbre sp>5);d><3;d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">5 sp>3;d><3}d ivclassNa="meec-li">53}d><3}d ivclassNa="meco"><}d>}d>3}d> 44AEfunc361B0getDescrip1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v111(>6361B0nu1<111) spans="tyle--0:#7FDBCA;--1:#09">6111)>361B0st3F<53 {divclass="Nameec-">de44AEsw3F53 (valu53 >dent< spans="tyle--0:#C792EA;--1:#88">44AE >30<9821 spans="tyle--0:#D6DEEB;--1:#40">39821>dent < spans="tyle--0:#C792EA;--1:#88">44AEre >31<111" spans="tyle--0:#ECC48D;--1:#98">4E4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">dent< spans="tyle--0:#C792EA;--1:#88">44AE >30<9822 spans="tyle--0:#D6DEEB;--1:#40">39822>dent < spans="tyle--0:#C792EA;--1:#88">44AEre >31<111" spans="tyle--0:#ECC48D;--1:#98">4E4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">dent< spans="tyle--0:#C792EA;--1:#88">44AEdef >3dent < spans="tyle--0:#C792EA;--1:#88">44AEre >31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dunk111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">3F<53 spans="tyle--0:#D6DEEB;--1:#40">353 >3c44AEfunc361B0processV1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53i111(>6361B0st1<111) spans="tyle--0:#7FDBCA;--1:#09">6111)>361B03F<53 {divclass="Nameec-">de44AEsw3F53 (inpu53 >dent< spans="tyle--0:#C792EA;--1:#88">44AE >31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Ds111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">3F53 < spans="tyle--0:#D6DEEB;--1:#40">3F53con >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DStartin111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Nameec-">dent < spans="tyle--0:#C792EA;--1:#88">44AEb >353)>dent< spans="tyle--0:#C792EA;--1:#88">44AE >31<111" spans="tyle--0:#ECC48D;--1:#98">4E4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">3F53 < spans="tyle--0:#D6DEEB;--1:#40">3F53con >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DEndin111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Nameec-">dent < spans="tyle--0:#C792EA;--1:#88">44AEb >353)>dent< spans="tyle--0:#C792EA;--1:#88">44AEdef >33F53 < spans="tyle--0:#D6DEEB;--1:#40">3F53con >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DProcessin111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Nameec-">dent < spans="tyle--0:#C792EA;--1:#88">44AEb >353)>3F<53 spans="tyle--0:#D6DEEB;--1:#40">353 >3< }> }>
This rule is not configurable.
If you have a specific code style guide that requires default clauses to appear in a different position, you might choose to disable this rule.
However, this is generally not recommended as it goes against common JavaScript conventions.