Reports matchAll() and replaceAll() calls with regex arguments missing the global flag.
✅ This rule is included in the ts logical presets.
When calling String.prototype.matchAll() or String.prototype.replaceAll() with a regular expression, the regex must have the global (g) flag.
Without it, JavaScript throws a TypeError at runtime.
This rule detects regex literals and RegExp constructor calls that are missing the global flag when passed to these methods.
1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dhello wor1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">A1"sp>B0matchA5<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:#D6DEEB;--1:#403F">531/sp><);d ivclassNa="meco"><);d>);d>);d>1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dhello wor1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">A1"sp>B0replaceA5<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:#D6DEEB;--1:#403F">531/sp><, sp ansty="le--0:#D9F5DD;--1:#1111">1, sp><1"sp ansty="le--0:#ECC48D;--1:#984E">41"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0teAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dexamp1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp><3;d ivclassNa="meec-li">53teAB0matchA5<3(sp ansty="le--0:#7FDBCA;--1:#096E">72n3(sp>5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0RegE3 sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">41"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">53)1"sp>3;d><);d ivclassNa="meco"><);d>);d>);d> 1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dhello w111">1<111" spans="tyle--0:#C792EA;--1:#88">4111"><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0matc4AE.>31<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fo spans="tyle--0:#D9F5DD;--1:#11">188Fo><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fg spans="tyle--0:#D6DEEB;--1:#40">3F88Fg><53) ;divclass="Name">/g)>53)><;di vdivclass="Nameexpressive-">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dhello w111">1<111" spans="tyle--0:#C792EA;--1:#88">4111"><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0replac4AE.>31<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fo spans="tyle--0:#D9F5DD;--1:#11">188Fo><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fg spans="tyle--0:#D6DEEB;--1:#40">3F88Fg><53, spans="tyle--0:#D9F5DD;--1:#11">153, ><111" spans="tyle--0:#ECC48D;--1:#98">4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name"><0")>0")>53)>;di><;di vdivclass="Nameexpressive-">44AEco61B044A1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dexa111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">3F534<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0matc4AE.>36E7<2new spans="tyle--0:#D6DEEB;--1:#40">32new>61B0Re31<111" spans="tyle--0:#ECC48D;--1:#98">4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53, spans="tyle--0:#D9F5DD;--1:#11">153, ><111" spans="tyle--0:#ECC48D;--1:#98">4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F5111"><3)) ;divclass="Name"><"))>"))>3))>;di><;di vdivclass="Nameexpressive-">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dhello w111">1<111" spans="tyle--0:#C792EA;--1:#88">4111"><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0replac4AE.>31<111" spans="tyle--0:#ECC48D;--1:#98">4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53, spans="tyle--0:#D9F5DD;--1:#11">153, ><111" spans="tyle--0:#ECC48D;--1:#98">4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name"><0")>0")>53)>;di>
This rule is not configurable.
If you’re transpiling to an environment without matchAll() or replaceAll() support and have polyfills that don’t enforce the global flag requirement, you might want to disable this rule.