Reports regular expression flags that have no effect on the pattern.
✅ This rule is included in the ts logical presets.
Reports regular expression flags that have no effect on the pattern.
Unused flags add unnecessary complexity and may mislead readers about the regex’s behavior.
The i flag is useless when the pattern contains no ASCII letters (A-Za-z).
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F11/sp><23sp ansty="le--0:#D9F5DD;--1:#1111">123sp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>5<3;d ivclassNa="meec-li">AEconsB0digiAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#82AAFF;--1:#3B61">B01/sp><\dsp ansty="le--0:#7FDBCA;--1:#096E">7\dsp><2+sp ansty="le--0:#D9F5DD;--1:#1111">12+sp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>53;d><3;d ivclassNa="meco">3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688111/>1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fi spans="tyle--0:#D6DEEB;--1:#40">388Fi>44AEco61B0alphanum446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#82AAFF;--1:#3B">61B0[a-z111/><0-9] spans="tyle--0:#7FDBCA;--1:#09">60-9]>1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fi spans="tyle--0:#D6DEEB;--1:#40">388Fi><+/i>+/i>
The m flag is useless when the pattern contains no ^ or $ anchors.
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8Fa1/sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>5<3;d ivclassNa="meec-li">AEconsB0whitespaAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#82AAFF;--1:#3B61">B01/sp><\ssp ansty="le--0:#7FDBCA;--1:#096E">7\ssp><2+sp ansty="le--0:#D9F5DD;--1:#1111">12+sp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>53;d><3;d ivclassNa="meco">3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#C792EA;--1:#88">4111/><4AE^ spans="tyle--0:#5CA7E4;--1:#3A">6884AE^>1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fm spans="tyle--0:#D6DEEB;--1:#40">388Fm>44AEco61B0lin446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688111/>4<4AE$ spans="tyle--0:#D9F5DD;--1:#11">14AE$><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fm spans="tyle--0:#D6DEEB;--1:#40">388Fm><$/m>$/m>
The s flag is useless when the pattern contains no . metacharacters.
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8Fa1/sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>5<3;d ivclassNa="meec-li">AEconsB0escapAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>82<\.sp ansty="le--0:#5CA7E4;--1:#3A68">8\.sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>53;d><3;d ivclassNa="meco">3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fa spans="tyle--0:#82AAFF;--1:#3B">688Fa><1B0. spans="tyle--0:#5CA7E4;--1:#3A">61B0.><88Fb spans="tyle--0:#D9F5DD;--1:#11">188Fb><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fs spans="tyle--0:#D6DEEB;--1:#40">388Fs>44AEco61B0multi446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#82AAFF;--1:#3B">6111/><1B0. spans="tyle--0:#7FDBCA;--1:#09">61B0.>688Fcon6<1B0. spans="tyle--0:#7FDBCA;--1:#09">61B0.>1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fs spans="tyle--0:#D6DEEB;--1:#40">388Fs><*/s>*/s>
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F11/sp><23sp ansty="le--0:#D9F5DD;--1:#1111">123sp><1/sp ansty="le--0:#5CA7E4;--1:#3A68">8Fi1/sp>5<3;d ivclassNa="meco">3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">688111/>1<111/ spans="tyle--0:#D6DEEB;--1:#40">3111/><23/>23/>
This rule is not configurable.
If you add flags preemptively to patterns you intend to extend later, you might want to disable this rule.