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.

const pattern = /[A-z]/;

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

const pattern = /[0-A]/;
const pattern = /[\cA-Z]/;

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.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.