]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | # Disallow Multiline Strings (no-multi-str) |
2 | ||
3 | It's possible to create multiline strings in JavaScript by using a slash before a newline, such as: | |
4 | ||
5 | ```js | |
6 | var x = "Line 1 \ | |
7 | Line 2"; | |
8 | ``` | |
9 | ||
10 | Some consider this to be a bad practice as it was an undocumented feature of JavaScript that was only formalized later. | |
11 | ||
12 | ## Rule Details | |
13 | ||
14 | This rule is aimed at preventing the use of multiline strings. | |
15 | ||
16 | Examples of **incorrect** code for this rule: | |
17 | ||
18 | ```js | |
19 | /*eslint no-multi-str: "error"*/ | |
456be15e TL |
20 | |
21 | var x = "some very \ | |
22 | long text"; | |
eb39fafa DC |
23 | ``` |
24 | ||
25 | Examples of **correct** code for this rule: | |
26 | ||
27 | ```js | |
28 | /*eslint no-multi-str: "error"*/ | |
29 | ||
456be15e TL |
30 | var x = "some very long text"; |
31 | ||
32 | var x = "some very " + | |
33 | "long text"; | |
eb39fafa | 34 | ``` |