Skip to content

regexObscureRanges

Reports obscure character ranges in regular expressions.

✅ This rule is included in the ts logical and logicalStrict presets.

Character ranges like A-z or 0-A span across non-obvious character sets and can lead to unexpected matching behavior. Standard alphanumeric ranges like a-z, A-Z, and 0-9 are preferable. This rule reports obscure character ranges in regular expressions.

AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#82AAFF;--1:#3B61">B0[A-1<1/sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#82AAFF;--1:#3B">61B0[A-Z1<111/ spans="tyle--0:#D6DEEB;--1:#40">3

The range A-z includes characters like [, \, ], ^, _, and backtick in addition to letters.

AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#82AAFF;--1:#3B61">B0[0-1<1/sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#82AAFF;--1:#3B">61B0[0<-9A] spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#D6DEEB;--1:#40">3
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#82AAFF;--1:#3B61">B0[\cA-1<1/sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#82AAFF;--1:#3B">61B0[\cA-<\cZ] spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#D6DEEB;--1:#40">3

This rule is not configurable.

If you intentionally use non-standard character ranges for specific matching needs, or if your codebase has established patterns that rely on these ranges, you might want to disable this rule.