mirror of
https://git.proxmox.com/git/pve-eslint
synced 2025-10-19 04:23:02 +00:00

includes a (minimal) working wrapper Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
55 lines
933 B
Markdown
55 lines
933 B
Markdown
# Disallow unnecessary escape usage (no-useless-escape)
|
|
|
|
Escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect, as demonstrated in the following example:
|
|
|
|
```js
|
|
let foo = "hol\a"; // > foo = "hola"
|
|
let bar = `${foo}\!`; // > bar = "hola!"
|
|
let baz = /\:/ // same functionality with /:/
|
|
```
|
|
|
|
## Rule Details
|
|
|
|
This rule flags escapes that can be safely removed without changing behavior.
|
|
|
|
Examples of **incorrect** code for this rule:
|
|
|
|
```js
|
|
/*eslint no-useless-escape: "error"*/
|
|
|
|
"\'";
|
|
'\"';
|
|
"\#";
|
|
"\e";
|
|
`\"`;
|
|
`\"${foo}\"`;
|
|
`\#{foo}`;
|
|
/\!/;
|
|
/\@/;
|
|
|
|
```
|
|
|
|
Examples of **correct** code for this rule:
|
|
|
|
```js
|
|
/*eslint no-useless-escape: "error"*/
|
|
|
|
"\"";
|
|
'\'';
|
|
"\x12";
|
|
"\u00a9";
|
|
"\371";
|
|
"xs\u2111";
|
|
`\``;
|
|
`\${${foo}}`;
|
|
`$\{${foo}}`;
|
|
/\\/g;
|
|
/\t/g;
|
|
/\w\$\*\^\./;
|
|
|
|
```
|
|
|
|
## When Not To Use It
|
|
|
|
If you don't want to be notified about unnecessary escapes, you can safely disable this rule.
|