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