noUselessStringRaw
¥Summary
-
规则生效日期:
v1.9.4¥Rule available since:
v1.9.4 -
诊断类别:
lint/complexity/noUselessStringRaw¥Diagnostic Category:
lint/complexity/noUselessStringRaw -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
¥How to configure
{ "linter": { "rules": { "complexity": { "noUselessStringRaw": "error" } } }}¥Description
禁止在模板字符串字面量中使用不必要的 String.raw 函数(不带任何转义序列)。
¥Disallow unnecessary String.raw function in template string literals without any escape sequence.
当包含没有任何转义序列的原始字符串时,String.raw 无效。
¥String.raw is useless when contains a raw string without any escape-like sequence.
¥Examples
¥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.raw`a`;
│ ^^^^^^^^^^^^^
2 │
ℹ Remove the String.raw call because 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.raw`a ${v}`;
│ ^^^^^^^^^^^^^^^^^^
2 │
ℹ Remove the String.raw call because it’s useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \”, \‘.
¥Valid
String.raw`\n ${a}`;String.raw`\n`;¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号