regexLetterCasing
Reports inconsistent letter casing in regex sequences.
✅ This rule is included in the ts stylisticStrict presets.
Consistent letter casing in regex escape sequences improves readability and makes patterns easier to compare. This rule enforces:
- Lowercase for hexadecimal digits in
\x,\u, and\u{}escape sequences - Lowercase for literal letters in case-insensitive patterns (with the
iflag) - Uppercase for control character letters in
\cescape sequences
Examples
Section titled “Examples”/\u000A/;/\x0A/;/\u{1F4A9}/u;/\ca/u;/Regexp/i;/[A-Z]/i;/\u000a/;/\x0a/;/\u{1f4a9}/u;/\cA/u;/regexp/i;/[a-z]/i;// Uppercase is fine without the i flag/REGEXP/;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If your codebase has an established convention of using uppercase hexadecimal digits in escape sequences, or if you prefer a different casing convention than what this rule enforces, you may want to disable it.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
regexp/letter-case
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.