Skip to content

regexIgnoreCaseFlags

Reports regex patterns that can be simplified by using the i (ignore case) flag.

✅ This rule is included in the ts logical presets.

When a character class contains both upper and lower case versions of the same letters, the pattern can be simplified by using the i (ignore case) flag. This makes the regex shorter and clearer by eliminating redundant character class entries.

const pattern = /[aA]/;
const pattern = /[a-zA-Z]/;
const pattern = /[aAbBcC]/;

This rule is not configurable.

If you need explicit control over case matching in your regex patterns, or if your codebase intentionally avoids the i flag for performance or compatibility reasons, you might prefer to disable this rule. Some legacy JavaScript environments may have inconsistent behavior with the i flag for non-ASCII characters.

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