Skip to content

noMultiStr

¥Summary

¥How to configure

biome.json
{
"linter": {
"rules": {
"nursery": {
"noMultiStr": "error"
}
}
}
}

¥Description

禁止通过转义换行符创建多行字符串。

¥Disallow creating multiline strings by escaping newlines.

不建议转义换行符来创建多行字符串,因为这可能会导致反斜杠后出现意外的空格,从而引发一些不易察觉的错误。

¥Escaping newlines to create multiline strings is discouraged because it can lead to subtle errors caused by unexpected whitespace after the backslash.

¥Examples

¥Invalid

const foo =
"Line 1\n\
Line 2";
code-block.js:2:5 lint/nursery/noMultiStr ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Escaping newlines to create multiline strings is disallowed.

1 │ const foo =
> 2 │ “Line 1\n\
^^^^^^^^^^
> 3 │ Line 2”;
^^^^^^^
4 │

¥Valid

const foo = "Line 1\nLine 2";
const bar = `Line 1
Line 2`;

¥Related links