跳转到内容

useTemplate

此内容尚不支持你的语言。

biome.json
{
"linter": {
"rules": {
"style": {
"useTemplate": "error"
}
}
}
}

Prefer template literals over string concatenation.

const s = foo + "baz";
code-block.js:1:11 lint/style/useTemplate  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Template literals are preferred over string concatenation.

> 1 │ const s = foo + “baz”;
^^^^^^^^^^^
2 │

Unsafe fix: Use a template literal.

1 - const·s·=·foo·+·baz;
1+ const·s·=·`${foo}baz`;
2 2

const s = 1 + 2 + "foo" + 3;
code-block.js:1:11 lint/style/useTemplate  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Template literals are preferred over string concatenation.

> 1 │ const s = 1 + 2 + “foo” + 3;
^^^^^^^^^^^^^^^^^
2 │

Unsafe fix: Use a template literal.

1 - const·s·=·1·+·2·+·foo·+·3;
1+ const·s·=·`${1·+·2}foo${3}`;
2 2

const s = 1 * 2 + "foo";
code-block.js:1:11 lint/style/useTemplate  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Template literals are preferred over string concatenation.

> 1 │ const s = 1 * 2 + “foo”;
^^^^^^^^^^^^^
2 │

Unsafe fix: Use a template literal.

1 - const·s·=·1·*·2·+·foo;
1+ const·s·=·`${1·*·2}foo`;
2 2

const s = 1 + "foo" + 2 + "bar" + "baz" + 3;
code-block.js:1:11 lint/style/useTemplate  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Template literals are preferred over string concatenation.

> 1 │ const s = 1 + “foo” + 2 + “bar” + “baz” + 3;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Unsafe fix: Use a template literal.

1 - const·s·=·1·+·foo·+·2·+·bar·+·baz·+·3;
1+ const·s·=·`${1}foo${2}barbaz${3}`;
2 2

let s = "foo" + "bar" + `baz`;
let s = `value: ${1}`;