noUselessStringRaw
Summary
Section titled “Summary”- Rule available since:
v1.9.4
- Diagnostic Category:
lint/complexity/noUselessStringRaw
- This rule is recommended, which means is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is information.
Description
Section titled “Description”Disallow unnecessary String.raw
function in template string literals without any escape sequence.
String.raw
is useless when contains a raw string without any escape-like sequence.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”String.raw`a`;
code-block.js:1:1 lint/complexity/noUselessStringRaw ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ String.raw is useless when the raw string doesn’t contain any escape sequence.
> 1 │ String.rawa
;
│ ^^^^^^^^^^^^^
2 │
ℹ Remove the String.raw call beacause it’s useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \”, \’.
String.raw`a ${v}`;
code-block.js:1:1 lint/complexity/noUselessStringRaw ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ String.raw is useless when the raw string doesn’t contain any escape sequence.
> 1 │ String.rawa ${v}
;
│ ^^^^^^^^^^^^^^^^^^
2 │
ℹ Remove the String.raw call beacause it’s useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \”, \‘.
String.raw`\n ${a}`;
String.raw`\n`;
How to configure
Section titled “How to configure”{ "linter": { "rules": { "complexity": { "noUselessStringRaw": "error" } } }}