Skip to content

regexControlCharacterEscapes

Reports control characters that are not escaped using standard escape sequences.

✅ This rule is included in the ts logical and logicalStrict presets.

Enforces consistent escaping of control characters in regular expressions by requiring standard escape sequences (\0, \t, \n, \v, \f, \r) instead of hex, unicode, or control character escapes.

const pattern = /\x0a/;
const pattern = /\u000a/;
const pattern = /\cJ/;
const pattern = /\u{a}/u;

This rule is not configurable.

If your codebase has an established convention of using hex or unicode escapes for control characters, or if you need consistency with generated code that uses these formats, you may disable this rule.

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