Reports replacement strings with unescaped $ that should use $$.
✅ This rule is included in the ts stylistic and stylisticStrict presets.
Enforces escaping the $ character as $$ when using it literally in the replacement argument of String.prototype.replace() and String.prototype.replaceAll().
In these methods, $ has special meaning for substitution patterns like $& (matched substring), $1 (first capture group), etc.
An unescaped $ followed by an unrecognized character will be treated as a literal $, but this behavior is confusing and error-prone.
This rule reports unescaped $ characters in replacement strings that are not valid substitution pattern matchers.
AEconsB0resuAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D1"sp><€100 spans="tyle--0:#D9F5DD;--1:#11">1€100><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/><88 F€spa="nstyle--0:#D9F5DD;--1:#">188><1111 1/spa="nstyle--0:#C792EA;--1:#">881111><44AE , spa="nstyle--0:#D9F5DD;--1:#">144AE><1111 1"spa="nstyle--0:#ECC48D;--1:#">91111><84E4 D$spa="nstyle--0:#D9F5DD;--1:#">184E4><1111 1"spa="nstyle--0:#D6DEEB;--1:#">401111><3F5 3);divcla="ssNa">€/>/€/>3F5> <, "$");divstarligh t-tab-ite="mdataLabe">< not-conte ntfigcapt="ioncla"> not-conte>;--1:#<8844 AEcon="st spanstyle--0:#82AAFF">;--1:#8844><3B61 B0res="ultspanstyle--0:#C792EA">;--3B61><1:#8 844AE=" = spanstyle--0:#D9F5DD">;1:#8><--1: #1111="11"spanstyle--0:#ECC48D">;--1--1:><:#98 4E4="D€100spanstyle--0:#D9F5">DEFF;--1:<#3B6 1B0re="placespanstyle--0:#D6DE">E#3B6>DE<4;-- 1:#3A="688F€spanstyle--0:#D9">F4;--><5DD; --1:#="111111/spanstyle--0:#C7">925DD;>F<5DD; --1:#="111111"spanstyle--0:#EC">C45DD;><8D;- -1:#9="84E4D$$spanstyle--0:#D9">F8D;-><5DD; --1:#="111111"spanstyle--0:#D6">DE5DD;>, "$");divstarligh>
AEconsB0resuAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Da1"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:#82AAFF;--1:#3B61">B1/sp><0.sp ansty="le--0:#D9F5DD;--1:#1111">10.sp><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><$xsp ansty="le--0:#D9F5DD;--1:#1111">1$xsp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meco"><);d>);d>);d> 44AEco61B0re44A1<111" spans="tyle--0:#ECC48D;--1:#98">4E4111">1<111" spans="tyle--0:#C792EA;--1:#88">4111"><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0rep4AE.>31<111/ spans="tyle--0:#82AAFF;--1:#3B">6111/><1B0. spans="tyle--0:#D9F5DD;--1:#11">11B0.><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">53)>
AEconsB0matchedSubstriAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Da1"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:#82AAFF;--1:#3B61">B1/sp><0.sp ansty="le--0:#D9F5DD;--1:#1111">10.sp><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><$&sp ansty="le--0:#D9F5DD;--1:#1111">1$&sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meec-li">AEconsB0firstGroAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Da1"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>B<0.sp ansty="le--0:#5CA7E4;--1:#3A68">80.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><);d ivclassNa="meec-li">AEconsB0namedGroAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Da1"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>B0ch?8sp ansty="le--0:#82AAFF;--1:#3B61">Bsp><0.sp ansty="le--0:#5CA7E4;--1:#3A68">80.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">4D$<cha1"sp>sp ansty="le--0:#D9F5DD;--1:#1111">1sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp>);d><);d ivclassNa="meec-li">AEconsB0literalDollAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Da1"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:#82AAFF;--1:#3B61">B1/sp><0.sp ansty="le--0:#D9F5DD;--1:#1111">10.sp><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><$$sp ansty="le--0:#D9F5DD;--1:#1111">1$$sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp>);d><);d ivclassNa="meco">.)/, "$");const literalDollar = "abc".replace(/./, "$$""><);d>);d>);d>
This rule is not configurable.
If you intentionally rely on the behavior where $ followed by an unrecognized character produces a literal $, you might prefer to disable this rule.