Why is this an issue?

Entries in the ASCII table below code 32 are known as control characters or non-printing characters. As they are not common in JavaScript strings, using these invisible characters in regular expressions is most likely a mistake.

const pattern1 = /\x1a/;             // Noncompliant: 1a (23 base 10) is less than 32
const pattern2 = new RegExp('\x1a'); // Noncompliant: 1a (23 base 10) is less than 32

Instead, one should only match printable characters in regular expressions.

const pattern1 = /\x20/;
const pattern2 = new RegExp('\x20');

Exceptions

Control characters used to match terminal introducers are intentional. The rule recognizes ESC followed by a required Control Sequence Introducer (CSI) bracket [ or Operating System Command (OSC) bracket ]. It also recognizes the single-character C1 OSC introducer \x9d. The rule exempts BEL and ESC terminators in the supported bounded OSC forms below:

The rule also recognizes groups that contain only the supported introducers or terminators. For example, the following pattern uses the bounded OSC form found in ansi-regex:

const osc = /(?:\x1b\]|\x9d)[^\x07\x1b\x9c\x9d]*(?:\x07|\x1b\\|\x9c)/;

The exception recognizes deliberate delimiter matching; it does not validate the terminal protocol. The rule may still report other forms, including optional, sibling, or mixed introducers, mixed endings, wildcard payloads, Unicode property escapes, backreferences, split delimiters, or introducers used only in lookarounds.

These exceptions also cover brackets written through groups or exact-one quantifiers, such as /\x1b(?:\[)31m/ or /\x1b\]{1}0;title\x07/. Each group alternative must match the same single bracket.

Resources

Documentation