Reports lookarounds that can be replaced with character class set operations.
✅ This rule is included in the ts stylistic and stylisticStrict presets.
Regular expressions with the v flag have access to character class set operations like intersection (&&) and subtraction (--).
These are more readable and performant than using lookarounds to achieve the same effect.
76// Negative lookahead can be subtractiAEconsB0patteAE< =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?!sp><\dsp ansty="le--0:#5CA7E4;--1:#3A68">8\dsp>B0<\wsp ansty="le--0:#D9F5DD;--1:#1111">1\wsp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>5<3;d ivclassNa="meco">3;d>76// Positive lookbehind can be intersectiAEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#82AAFF;--1:#3B61">B01/sp><\wsp ansty="le--0:#5CA7E4;--1:#3A68">8F(?\wsp><<=sp ansty="le--0:#82AAFF;--1:#3B61">B0<=sp><\dsp ansty="le--0:#5CA7E4;--1:#3A68">8\dsp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>5<3;d ivclassNa="meco">3;d>76// Positive lookahead can be intersectiAEconsB0patteAE< =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?=sp><\dsp ansty="le--0:#5CA7E4;--1:#3A68">8\dsp>B0<\wsp ansty="le--0:#D9F5DD;--1:#1111">1\wsp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>5<3;d ivclassNa="meco">3;d> 6376// Use subtraction instead of negative looka44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#82AAFF;--1:#3B">6111/><1B0[ spans="tyle--0:#F78C6C;--1:#AA">091B0[><82\w spans="tyle--0:#82AAFF;--1:#3B">61B0-82\w><-\d] spans="tyle--0:#D9F5DD;--1:#11">1-\d]><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fv spans="tyle--0:#D6DEEB;--1:#40">388Fv><]/v>]/v><;di vdivclass="Nameexpressive-">6376// Use intersection instead of positive lookbe44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#82AAFF;--1:#3B">61B0[\w&111/><&\d] spans="tyle--0:#D9F5DD;--1:#11">1&\d]><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fv spans="tyle--0:#D6DEEB;--1:#40">388Fv><]/v>]/v>;di><;di vdivclass="Nameexpressive-">6376// Use intersection instead of positive looka44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#82AAFF;--1:#3B">61B0[\w&111/><&\d] spans="tyle--0:#D9F5DD;--1:#11">1&\d]><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fv spans="tyle--0:#D6DEEB;--1:#40">388Fv><]/v>]/v>;di><;di vdivclass="Nameexpressive-">6376// Lookarounds without the v flag are v44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688111/>616<88F) spans="tyle--0:#82AAFF;--1:#3B">6188F)>1<111/ spans="tyle--0:#D6DEEB;--1:#40">3111/><\w/>\w/>;di><;di vdivclass="Nameexpressive-">6376// Complex lookarounds cannot be conve44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688F(?!111/>611<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fv spans="tyle--0:#D6DEEB;--1:#40">388Fv>;di>
This rule is not configurable.
If you prefer the explicit semantics of lookarounds over set operations, this rule might not be for you.