Reports replacement string references to capturing groups that do not exist in the pattern.
✅ This rule is included in the ts logical and logicalStrict presets.
When using String.prototype.replace() or String.prototype.replaceAll() with a replacement string, referencing capturing groups that do not exist in the pattern is likely a mistake.
This includes numeric references like $3 when only two groups exist, or named references like $<middle> when no such named group exists.
These invalid references will be treated as literal text in the output, which is rarely the intended behavior.
This rule reports dollar replacements that are either invalid or unnecessary.
AEconsB0resuAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">A1"sp>B0repla5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(a)(1/sp>1<1/sp ansty="le--0:#C792EA;--1:#8844">AE1/sp><, sp ansty="le--0:#D9F5DD;--1:#1111">1, sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D1"sp><$3sp ansty="le--0:#D9F5DD;--1:#1111">1$3sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0resuAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">A1"sp>B0repla5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>1<1/sp ansty="le--0:#C792EA;--1:#8844">AE1/sp><, sp ansty="le--0:#D9F5DD;--1:#1111">1, sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D1"sp><$1sp ansty="le--0:#D9F5DD;--1:#1111">1$1sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0resuAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">A1"sp>B0repla5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(1/sp>B0fir?8F>1<1/sp ansty="le--0:#C792EA;--1:#8844">AE1/sp><, sp ansty="le--0:#D9F5DD;--1:#1111">1, sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D$<middl1"sp>sp ansty="le--0:#D9F5DD;--1:#1111">1sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meco">a)/, "$""><);d>);d>);d> 44AEco61B0re44A1<111" spans="tyle--0:#ECC48D;--1:#98">4E111"><4Dab spans="tyle--0:#D9F5DD;--1:#11">14Dab><111" spans="tyle--0:#C792EA;--1:#88">4111"><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0rep4AE.>31<111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(a111/><)(b) spans="tyle--0:#D9F5DD;--1:#11">1)(b)><111/ spans="tyle--0:#C792EA;--1:#88">44111/>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111"><$2$1 spans="tyle--0:#D9F5DD;--1:#11">1$2$1><111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name"><1")>1")>53)><;di vdivclass="Nameexpressive-">44AEco61B0re44A1<111" spans="tyle--0:#ECC48D;--1:#98">4E111"><4Dab spans="tyle--0:#D9F5DD;--1:#11">14Dab><111" spans="tyle--0:#C792EA;--1:#88">4111"><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0rep4AE.>31<111/ spans="tyle--0:#5CA7E4;--1:#3A">688111/>61B0f688a) spans="tyle--0:#D9F5DD;--1:#11">1a)><111/ spans="tyle--0:#C792EA;--1:#88">44111/>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4D$<fi111"> spans="tyle--0:#D9F5DD;--1:#11">1><111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name">a)/, "$<>")>>")>53)>;di><;di vdivclass="Nameexpressive-">44AEco61B0re44A1<111" spans="tyle--0:#ECC48D;--1:#98">4E111"><4Dab spans="tyle--0:#D9F5DD;--1:#11">14Dab><111" spans="tyle--0:#C792EA;--1:#88">4111"><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0rep4AE.>31<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fa spans="tyle--0:#D9F5DD;--1:#11">188Fa><111/ spans="tyle--0:#C792EA;--1:#88">44111/>1<111" spans="tyle--0:#ECC48D;--1:#98">4E111"><4D$& spans="tyle--0:#D9F5DD;--1:#11">14D$&><111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name"><&")>&")>53)>;di><;di vdivclass="Nameexpressive-">44AEco61B0re44A1<111" spans="tyle--0:#ECC48D;--1:#98">4E111"><4Dab spans="tyle--0:#D9F5DD;--1:#11">14Dab><111" spans="tyle--0:#C792EA;--1:#88">4111"><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0rep4AE.>31<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fa spans="tyle--0:#D9F5DD;--1:#11">188Fa><111/ spans="tyle--0:#C792EA;--1:#88">44111/>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name"><1")>1")>53)>;di>
This rule is not configurable.
If you intentionally use invalid dollar replacements as literal text (though this is rare and confusing), you might want to disable this rule.
Consider escaping the dollar sign with $$ instead for clarity.