Pular para o conteúdo

noUselessStringRaw

Este conteúdo não está disponível em sua língua ainda.

Diagnostic Category: lint/nursery/noUselessStringRaw

Since: v1.9.4

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.

String.raw`a`;
code-block.js:1:1 lint/nursery/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/nursery/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`;