1 | # max-empty-lines
|
2 |
|
3 | Limit the number of adjacent empty lines.
|
4 |
|
5 |
|
6 | ```css
|
7 | a {}
|
8 | /* ← */
|
9 | /* ← */
|
10 | a {} /* ↑ */
|
11 | /** ↑
|
12 | * These lines */
|
13 | ```
|
14 |
|
15 | The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
|
16 |
|
17 | ## Options
|
18 |
|
19 | `int`: Maximum number of adjacent empty lines allowed.
|
20 |
|
21 | For example, with `2`:
|
22 |
|
23 | The following patterns are considered violations:
|
24 |
|
25 |
|
26 | ```css
|
27 | a {}
|
28 |
|
29 |
|
30 |
|
31 | b {}
|
32 | ```
|
33 |
|
34 | Comment strings are also checked -- so the following is a violation:
|
35 |
|
36 |
|
37 | ```css
|
38 | /*
|
39 | Call me Ishmael.
|
40 |
|
41 |
|
42 |
|
43 | Some years ago--never mind how long precisely-—...
|
44 | */
|
45 | ```
|
46 |
|
47 | The following patterns are _not_ considered violations:
|
48 |
|
49 |
|
50 | ```css
|
51 | a {}
|
52 | b {}
|
53 | ```
|
54 |
|
55 |
|
56 | ```css
|
57 | a {}
|
58 |
|
59 | b {}
|
60 | ```
|
61 |
|
62 |
|
63 | ```css
|
64 | a {}
|
65 |
|
66 |
|
67 | b {}
|
68 | ```
|
69 |
|
70 | ## Optional secondary options
|
71 |
|
72 | ### `ignore: ["comments"]`
|
73 |
|
74 | Only enforce the adjacent empty lines limit for lines that are not comments.
|
75 |
|
76 | For example, with `2` adjacent empty lines:
|
77 |
|
78 | The following patterns are considered violations:
|
79 |
|
80 |
|
81 | ```css
|
82 | /* horse */
|
83 | a {}
|
84 |
|
85 |
|
86 |
|
87 | b {}
|
88 | ```
|
89 |
|
90 | The following patterns are _not_ considered violations:
|
91 |
|
92 |
|
93 | ```css
|
94 | /*
|
95 | Call me Ishmael.
|
96 |
|
97 |
|
98 |
|
99 | Some years ago -- never mind how long precisely -- ...
|
100 | */
|
101 | ```
|
102 |
|
103 |
|
104 | ```css
|
105 | a {
|
106 | /*
|
107 | Comment
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | inside the declaration with a lot of empty lines...
|
113 | */
|
114 | color: pink;
|
115 | }
|
116 | ```
|