1 | # block-opening-brace-newline-after
|
2 |
|
3 | Require a newline after the opening brace of blocks.
|
4 |
|
5 |
|
6 | ```css
|
7 | a {
|
8 | ↑ color: pink; }
|
9 | /** ↑
|
10 | * The newline after this brace */
|
11 | ```
|
12 |
|
13 | This rule allows an end-of-line comment followed by a newline. For example,
|
14 |
|
15 |
|
16 | ```css
|
17 | a { /* end-of-line comment */
|
18 | color: pink;
|
19 | }
|
20 | ```
|
21 |
|
22 | Refer to [combining rules](../../../docs/user-guide/rules/combine.md) for more information on using this rule with [`block-opening-brace-newline-before`](../block-opening-brace-newline-before/README.md) to disallow single-line rules.
|
23 |
|
24 | The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
|
25 |
|
26 | ## Options
|
27 |
|
28 | `string`: `"always"|"always-multi-line"|"never-multi-line"`
|
29 |
|
30 | ### `"always"`
|
31 |
|
32 | There _must always_ be a newline after the opening brace.
|
33 |
|
34 | The following patterns are considered violations:
|
35 |
|
36 |
|
37 | ```css
|
38 | a{ color: pink; }
|
39 | ```
|
40 |
|
41 |
|
42 | ```css
|
43 | a{ color: pink;
|
44 | }
|
45 | ```
|
46 |
|
47 |
|
48 | ```css
|
49 | a{ /* end-of-line comment
|
50 | with a newline */
|
51 | color: pink;
|
52 | }
|
53 | ```
|
54 |
|
55 | The following patterns are _not_ considered violations:
|
56 |
|
57 |
|
58 | ```css
|
59 | a {
|
60 | color: pink; }
|
61 | ```
|
62 |
|
63 |
|
64 | ```css
|
65 | a
|
66 | {
|
67 | color: pink; }
|
68 | ```
|
69 |
|
70 |
|
71 | ```css
|
72 | a { /* end-of-line comment */
|
73 | color: pink;
|
74 | }
|
75 | ```
|
76 |
|
77 | ### `"always-multi-line"`
|
78 |
|
79 | There _must always_ be a newline after the opening brace in multi-line blocks.
|
80 |
|
81 | The following patterns are considered violations:
|
82 |
|
83 |
|
84 | ```css
|
85 | a{color: pink;
|
86 | }
|
87 | ```
|
88 |
|
89 | The following patterns are _not_ considered violations:
|
90 |
|
91 |
|
92 | ```css
|
93 | a { color: pink; }
|
94 | ```
|
95 |
|
96 |
|
97 | ```css
|
98 | a {
|
99 | color: pink; }
|
100 | ```
|
101 |
|
102 | ### `"never-multi-line"`
|
103 |
|
104 | There _must never_ be whitespace after the opening brace in multi-line blocks.
|
105 |
|
106 | The following patterns are considered violations:
|
107 |
|
108 |
|
109 | ```css
|
110 | a { color: pink;
|
111 | }
|
112 | ```
|
113 |
|
114 | The following patterns are _not_ considered violations:
|
115 |
|
116 |
|
117 | ```css
|
118 | a { color: pink; }
|
119 | ```
|
120 |
|
121 |
|
122 | ```css
|
123 | a {color: pink;
|
124 | }
|
125 | ```
|