noUselessStringRaw
Diagnostic Category: lint/nursery/noUselessStringRaw
Since: v1.9.4
Description
Section titled DescriptionDisallow 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 ExamplesInvalid
Section titled InvalidString.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, \\, \”, \‘.
  
Valid
Section titled ValidString.raw`\n ${a}`;String.raw`\n`;How to configure
Section titled How to configure{  "linter": {    "rules": {      "nursery": {        "noUselessStringRaw": "error"      }    }  }} 
 