src/content/docs/linter/rules/no-multi-str.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.8` - Diagnostic Category: [`lint/nursery/noMultiStr`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-multi-str`](https://eslint.org/docs/latest/rules/no-multi-str){
"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";
const foo = "Line 1\nLine 2";
const bar = `Line 1
Line 2`;