no-useless-escape
Configuration
rslint.config.ts
Disallow unnecessary escape characters.
Escaping non-special characters in strings, template literals, and regular expressions does not change behavior. Removing the redundant \ keeps the code simpler and avoids confusion.
Rule Details
This rule flags escapes that can be safely removed without changing behavior.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule has an object option:
allowRegexCharacters— array of characters whose\Xform is always allowed inside regular expressions, even when the\would otherwise be flagged. Useful for characters like-where the explicit escape can prevent the pattern from drifting into a range as the class grows.
allowRegexCharacters
Examples of incorrect code for the { "allowRegexCharacters": ["-"] } option:
Examples of correct code for the { "allowRegexCharacters": ["-"] } option:
When Not To Use It
If you do not want to be notified about unnecessary escapes, you can safely disable this rule.