Skip to content

regexControlCharacters

Reports control characters in regular expressions.

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

Reports control characters (code points U+0000 through U+001F) in regular expressions. Control characters in regex patterns are rarely intentional and can indicate a mistake or copy-paste error.

const pattern = /\x1f/;
const pattern = /\u001f/;
const pattern = /\cA/;

This rule is not configurable.

If your application intentionally processes binary data or protocols that use control characters, and you need to match them in regular expressions, you might prefer to disable this rule.

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