Skip to content

regexUnicodeEscapes

Enforces consistent Unicode escape style in regex patterns by preferring codepoint escapes.

✅ This rule is included in the ts stylistic presets.

Enforces consistent Unicode escape style in regex patterns by preferring \u{XXXX} (codepoint escape) over \uXXXX (4-digit Unicode escape) when the u or v flag is present.

The \u{...} format is more flexible, readable, and consistent with the modern Unicode handling in JavaScript.

const pattern = /\u0041/u;
const pattern = /[\u0041\u0042]/u;
const pattern = /[\u0041-\u005A]/u;
const pattern = /\u0041/v;

This rule is not configurable.

If you need to support environments that do not have the u or v flag, or if you intentionally use 4-digit Unicode escapes as a stylistic preference, you might want to disable this rule.

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