1 | # string-no-newline
|
2 |
|
3 | Disallow (unescaped) newlines in strings.
|
4 |
|
5 |
|
6 | ```css
|
7 | a {
|
8 | content: "first
|
9 | second"; ↑
|
10 | } ↑
|
11 | /** ↑
|
12 | * The newline here */
|
13 | ```
|
14 |
|
15 | [The spec](https://www.w3.org/TR/CSS2/syndata.html#strings) says this: "A string cannot directly contain a newline. To include a newline in a string, use an escape representing the line feed character in ISO-10646 (U+000A), such as '\A' or '\00000a'." And also: "It is possible to break strings over several lines, for aesthetic or other reasons, but in such a case the newline itself has to be escaped with a backslash (\\)."
|
16 |
|
17 | ## Options
|
18 |
|
19 | ### `true`
|
20 |
|
21 | The following patterns are considered violations:
|
22 |
|
23 |
|
24 | ```css
|
25 | a {
|
26 | content: "first
|
27 | second";
|
28 | }
|
29 | ```
|
30 |
|
31 |
|
32 | ```css
|
33 | [title="something
|
34 | is probably wrong"] {}
|
35 | ```
|
36 |
|
37 |
|
38 | ```css
|
39 | a {
|
40 | font-family: "Times
|
41 | New
|
42 | Roman";
|
43 | }
|
44 | ```
|
45 |
|
46 | The following patterns are _not_ considered violations:
|
47 |
|
48 |
|
49 | ```css
|
50 | a {
|
51 | content: "first\Asecond";
|
52 | }
|
53 | ```
|
54 |
|
55 |
|
56 | ```css
|
57 | a {
|
58 | content: "first\\nsecond";
|
59 | }
|
60 | ```
|
61 |
|
62 |
|
63 | ```css
|
64 | [title="nothing\
|
65 | is wrong"] {}
|
66 | ```
|
67 |
|
68 |
|
69 | ```css
|
70 | a {
|
71 | font-family: "Times New Roman";
|
72 | }
|
73 | ```
|