A backslash escapes a character that means the same without it
What it finds
A backslash before a character that has no escape meaning, as in "\d" or '\"', is dropped: the string is the same without it. It suggests an escape that is not there, as when a regular expression is written as a string and "\d" was meant as "\\d".
Reported are backslashes in string and template literals before characters other than the escapes the language defines, line breaks, digits, the quote that delimits the literal and, in templates, ` `, $ and {. A backslash before / is left alone, since "<\/script>"` is written that way on purpose, and so are tagged templates, whose tag may read the raw text. The fix, which is safe, removes the backslash.
From the rule's source, redundant_escape.rs.
export const a = "\d+";tx0 reports: the backslash does nothingexport const b = '\"';tx0 reports: the backslash does nothingexport const c = "\n\t\\\"\u0041\x41";export const d = `price: \$5 \` ok`;export const e = "<\/script>";export const f = String.raw`\d`; Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:redundant-escape" = "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:redundant-escape] reason="..."tx0 explain tx0/ts:redundant-escape shows the same in the terminal. Found a false positive? Report it.