Reports non-constant quantifiers in lookaround assertions that could be simplified.
✅ This rule is included in the ts logical presets.
Reports non-constant quantifiers in lookaround assertions that could be simplified.
Lookahead and lookbehind assertions only check whether a pattern matches, not how much text it consumes.
Non-constant quantifiers at the end of lookaheads or start of lookbehinds can be replaced with their minimum.
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(?=1/sp>7<2*sp ansty="le--0:#5CA7E4;--1:#3A68">82*sp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meco">;d>/;d>3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(111/>=b) spans="tyle--0:#D9F5DD;--1:#11">1?=b)><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(?=1/sp>7<2+sp ansty="le--0:#5CA7E4;--1:#3A68">82+sp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meco">;d>/;d>3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(?111/><=ba) spans="tyle--0:#D9F5DD;--1:#11">1=ba)><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(?1/sp><=asp ansty="le--0:#7FDBCA;--1:#096E">72{4,=asp><9}sp ansty="le--0:#5CA7E4;--1:#3A68">89}sp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meco">;d>/;d>3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F111/><(?=a spans="tyle--0:#7FDBCA;--1:#09">6E7(?=a><2{4} spans="tyle--0:#5CA7E4;--1:#3A">62{4}><88F) spans="tyle--0:#D9F5DD;--1:#11">188F)><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/><})/>})/>
Lookbehinds match from right to left, so non-constant quantifiers at the start are problematic.
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(?1/sp><<=sp ansty="le--0:#82AAFF;--1:#3B61">B0[a-<=sp>7<2*sp ansty="le--0:#5CA7E4;--1:#3A68">82*sp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meco">;d>/;d>3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(111/><=) spans="tyle--0:#D9F5DD;--1:#11">1?<=)><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/><=)/>=)/>
This rule is not configurable.
If you are intentionally using non-constant quantifiers in lookarounds for documentation purposes or if you are building patterns dynamically, you might want to disable this rule.