A pattern matches a control code below U+0020 other than tab or a line break
What it finds
/\x1f/, /\u0000/: control characters other than tab and line breaks hardly ever appear in text a program matches. A pattern with one usually comes from a string with a single backslash where two were meant, as new RegExp("\x1b"), or matches binary data that a byte array handles better.
Characters below U+0020 count, except tab, line feed and carriage return, whether written as an escape or literally. Ranges such as [\x00-\x7f], which select a block of characters on purpose, are left alone.
From the rule's source, pattern_control_code.rs.
const a = /\x1b\[0m/;tx0 reports: this pattern matches a control characterconst b = new RegExp("\u0000");tx0 reports: this pattern matches a control characterconst c = /[\x00-\x7f]/;const d = /\t\n/; Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:pattern-control-code" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:pattern-control-code] reason="..."tx0 explain tx0/ts:pattern-control-code shows the same in the terminal. Found a false positive? Report it.