regexIgnoreCaseFlags
Reports regex patterns that can be simplified by using the i (ignore case) flag.
✅ This rule is included in the tslogicalandlogicalStrictpresets.
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.
Examples
Section titled “Examples”const pattern = /[aA]/;const pattern = /[a-zA-Z]/;const pattern = /[aAbBcC]/;const pattern = /[a]/i;const pattern = /[a-z]/i;const pattern = /[abc]/i;// Only lowercase letters - no redundancyconst pattern = /[a-z]/;// Only uppercase letters - no redundancyconst pattern = /[A-Z]/;// Already using the i flagconst pattern = /[a-z]/i;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
regexp/use-ignore-case
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.