noMultilineString
Summary
Section titled “Summary”- Rule available since:
v2.3.8 - Diagnostic Category:
lint/style/noMultilineString - This rule isn’t recommended, so you need to enable it.
- This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
no-multi-str
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "style": { "noMultilineString": "error" } } }}Description
Section titled “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
Section titled “Examples”Invalid
Section titled “Invalid”const foo = "Line 1\n\Line 2";code-block.js:2:5 lint/style/noMultilineString ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ 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.
const foo = "Line 1\nLine 2";const bar = `Line 1Line 2`;Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.