noUnusedTemplateLiteral
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/style/noUnusedTemplateLiteral¥Diagnostic Category:
lint/style/noUnusedTemplateLiteral -
此规则包含 safe 修复程序。
¥This rule has a safe fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
¥How to configure
{ "linter": { "rules": { "style": { "noUnusedTemplateLiteral": "error" } } }}¥Description
如果不需要插值和特殊字符处理,则禁止使用模板文字
¥Disallow template literals if interpolation and special-character handling are not needed
¥Examples
¥Invalid
const foo = `bar`code-block.js:1:13 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Do not use template literals if interpolation and special-character handling are not needed.
> 1 │ const foo = `bar`
│ ^^^^^
2 │
ℹ Safe fix: Replace with string literal
1 │ - const·foo·=·`bar`
1 │ + const·foo·=·“bar”
2 2 │
const foo = `bar `code-block.js:1:13 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Do not use template literals if interpolation and special-character handling are not needed.
> 1 │ const foo = `bar `
│ ^^^^^^
2 │
ℹ Safe fix: Replace with string literal
1 │ - const·foo·=·`bar·`
1 │ + const·foo·=·“bar·”
2 2 │
¥Valid
const foo = `barhas newline`;const foo = `"bar"`const foo = `'bar'`¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号