UNPKG

1.29 kBMarkdownView Raw
1# string-no-newline
2
3Disallow (unescaped) newlines in strings.
4
5<!-- prettier-ignore -->
6```css
7a {
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
21The following patterns are considered violations:
22
23<!-- prettier-ignore -->
24```css
25a {
26 content: "first
27 second";
28}
29```
30
31<!-- prettier-ignore -->
32```css
33[title="something
34is probably wrong"] {}
35```
36
37<!-- prettier-ignore -->
38```css
39a {
40 font-family: "Times
41 New
42 Roman";
43}
44```
45
46The following patterns are _not_ considered violations:
47
48<!-- prettier-ignore -->
49```css
50a {
51 content: "first\Asecond";
52}
53```
54
55<!-- prettier-ignore -->
56```css
57a {
58 content: "first\\nsecond";
59}
60```
61
62<!-- prettier-ignore -->
63```css
64[title="nothing\
65 is wrong"] {}
66```
67
68<!-- prettier-ignore -->
69```css
70a {
71 font-family: "Times New Roman";
72}
73```