Reports capturing groups in regular expressions that are never referenced.
✅ This rule is included in the ts logical presets.
Reports capturing groups in regular expressions that have no backreferences.
A capturing group without a backreference is considered “unused” and can typically be converted to a non-capturing group for clarity.
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(1/sp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meco">;d>/;d>3;d>AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(1/sp>B0na?8F>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meco">a)">;d>/;d>3;d>AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(a)(b)1/sp><\1sp ansty="le--0:#D9F5DD;--1:#1111">1\1sp><1/sp ansty="le--0:#D6DEEB;--1:#403F">531/sp><; sp ansty="le--0:#919F9F;--1:#5D63">76// (b) is never referenc; sp>AEconsB0patteAE <= sp ansty="le--0:#7FDBCA;--1:#096E">72n= sp>AB0RegE5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D(1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meco"><);d>);d>);d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(111/>1<111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>6376// Or use a non-capturing g44AEco61B0patt446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(111/>1?:a)><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/><;di vdivclass="Nameexpressive-">44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688111/>61B0688F>a<)\k< spans="tyle--0:#C5E478;--1:#3B">61B0)\k<>6<88F> spans="tyle--0:#D9F5DD;--1:#11">188F>><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>6376// Or use a non-capturing g44AEco61B0patt446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(111/>1?:a)><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>a)\k/;// Or use a non-capturing groupconst pattern2 = /(?:">;di><;di vdivclass="Nameexpressive-">44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(a)(?:111/>1<111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>6376// Or reference both gr44AEco61B0patt446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(a)(b)111/><\1\2 spans="tyle--0:#D9F5DD;--1:#11">1\1\2><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/><\2/>\2/>;di><;di vdivclass="Nameexpressive-">44AEco61B0pat44A6E7<2new spans="tyle--0:#C792EA;--1:#88">42new><4AE spans="tyle--0:#82AAFF;--1:#3B">61B0Re4AE >31<111" spans="tyle--0:#ECC48D;--1:#98">4E4111">09<82\\ spans="tyle--0:#ECC48D;--1:#98">482\\>1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Nameec-">6376// Or use a non-capturing g53)>44AEco61B0patt44A6E7<2new spans="tyle--0:#C792EA;--1:#88">42new><4AE spans="tyle--0:#82AAFF;--1:#3B">61B0Re4AE >31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D(111">1?:a)><111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name"><)")>)")>53)>;di>
This rule is not configurable.
If you use capturing groups for purposes other than backreferences within the regex itself (such as extracting matched groups via match() or exec()), you might prefer to disable this rule.
However, note that modern JavaScript provides named groups which are more readable for extraction purposes.
You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.