Skip to content

noMultiStr

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

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.

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

This string escapes a newline to span multiple lines.

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

Escaped newlines make string contents harder to read and can hide unexpected whitespace.

Use a template literal or include the newline explicitly instead.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

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