@@ -21,17 +21,17 @@ Having an inconsistent style distracts the reader from seeing the important part
2121This rule will enforce consistency of spacing before blocks. It is only applied on blocks that don’t begin on a new line.
2222
2323- This rule ignores spacing which is between ` => ` and a block. The spacing is handled by the ` arrow-spacing ` rule.
24- - This rule ignores spacing which is between a keyword and a block. The spacing is handled by the ` keyword-spacing ` rule.
24+ - This rule ignores spacing which is between a keyword (e.g. ` catch ` ) and a block. The spacing is handled by the ` keyword-spacing ` rule.
2525- This rule ignores spacing which is between ` : ` of a switch case and a block. The spacing is handled by the ` switch-colon-spacing ` rule.
2626
2727## Options
2828
2929This rule takes one argument. If it is ` "always" ` then blocks must always have at least one preceding space. If ` "never" `
3030then all blocks should never have any preceding space. If different spacing is desired for function
31- blocks, keyword blocks and classes , an optional configuration object can be passed as the rule argument to
31+ blocks, keyword blocks, classes, interfaces, enums and ts-modules , an optional configuration object can be passed as the rule argument to
3232configure the cases separately. If any value in the configuration object is ` "off" ` , then neither style will be enforced for blocks of that kind.
3333
34- ( e.g. ` { "functions": "never", "keywords": "always", "classes": "always" } ` )
34+ ( e.g. ` { "functions": "never", "keywords": "always", "classes": "always", "modules": "always" } ` )
3535
3636The default is ` "always" ` .
3737
@@ -59,6 +59,10 @@ try {} catch(a){}
5959class Foo {
6060 constructor (){}
6161}
62+
63+ namespace Foo{
64+ bar: string
65+ }
6266```
6367
6468:::
@@ -91,6 +95,10 @@ for (;;) {
9195}
9296
9397try {} catch (a) {}
98+
99+ namespace Foo {
100+ bar: string
101+ }
94102```
95103
96104:::
@@ -115,6 +123,10 @@ for (;;) {
115123}
116124
117125try {} catch (a) {}
126+
127+ namespace Foo {
128+ bar: string
129+ }
118130```
119131
120132:::
@@ -141,34 +153,42 @@ try{} catch(a){}
141153class Foo {
142154 constructor (){}
143155}
156+
157+ namespace Foo{
158+ bar: string
159+ }
144160```
145161
146162:::
147163
148- Examples of ** incorrect** code for this rule when configured ` { "functions": "never", "keywords": "always", "classes": "never" } ` :
164+ Examples of ** incorrect** code for this rule when configured ` { "functions": "never", "keywords": "always", "classes": "never", "modules": "always" } ` :
149165
150166::: incorrect
151167
152168``` js
153- /* eslint @stylistic/space-before-blocks: ["error", { "functions": "never", "keywords": "always", "classes": "never" }] */
169+ /* eslint @stylistic/space-before-blocks: ["error", { "functions": "never", "keywords": "always", "classes": "never", "modules": "never" }] */
154170
155171function a () {}
156172
157173try {} catch (a){}
158174
159- class Foo {
175+ class Foo {
160176 constructor () {}
161177}
178+
179+ namespace Foo {
180+ bar: string
181+ }
162182```
163183
164184:::
165185
166- Examples of ** correct** code for this rule when configured ` { "functions": "never", "keywords": "always", "classes": "never" } ` :
186+ Examples of ** correct** code for this rule when configured ` { "functions": "never", "keywords": "always", "classes": "never", "modules": "never" } ` :
167187
168188::: correct
169189
170190``` js
171- /* eslint @stylistic/space-before-blocks: ["error", { "functions": "never", "keywords": "always", "classes": "never" }] */
191+ /* eslint @stylistic/space-before-blocks: ["error", { "functions": "never", "keywords": "always", "classes": "never", "modules": "never" }] */
172192
173193for (;;) {
174194 // ...
@@ -181,16 +201,20 @@ describe(function(){
181201class Foo {
182202 constructor (){}
183203}
204+
205+ namespace Foo{
206+ bar: string
207+ }
184208```
185209
186210:::
187211
188- Examples of ** incorrect** code for this rule when configured ` { "functions": "always", "keywords": "never", "classes": "never" } ` :
212+ Examples of ** incorrect** code for this rule when configured ` { "functions": "always", "keywords": "never", "classes": "never", "modules": "never" } ` :
189213
190214::: incorrect
191215
192216``` js
193- /* eslint @stylistic/space-before-blocks: ["error", { "functions": "always", "keywords": "never", "classes": "never" }] */
217+ /* eslint @stylistic/space-before-blocks: ["error", { "functions": "always", "keywords": "never", "classes": "never", "modules": "never" }] */
194218
195219function a (){}
196220
@@ -199,16 +223,20 @@ try {} catch(a) {}
199223class Foo {
200224 constructor (){}
201225}
226+
227+ namespace Foo {
228+ bar: string
229+ }
202230```
203231
204232:::
205233
206- Examples of ** correct** code for this rule when configured ` { "functions": "always", "keywords": "never", "classes": "never" } ` :
234+ Examples of ** correct** code for this rule when configured ` { "functions": "always", "keywords": "never", "classes": "never", "modules": "never" } ` :
207235
208236::: correct
209237
210238``` js
211- /* eslint @stylistic/space-before-blocks: ["error", { "functions": "always", "keywords": "never", "classes": "never" }] */
239+ /* eslint @stylistic/space-before-blocks: ["error", { "functions": "always", "keywords": "never", "classes": "never", "modules": "never" }] */
212240
213241if (a){
214242 b ();
@@ -219,34 +247,46 @@ var a = function() {}
219247class Foo {
220248 constructor () {}
221249}
250+
251+ namespace Foo{
252+ bar: string
253+ }
222254```
223255
224256:::
225257
226- Examples of ** incorrect** code for this rule when configured ` { "functions": "never", "keywords": "never", "classes": "always" } ` :
258+ Examples of ** incorrect** code for this rule when configured ` { "functions": "never", "keywords": "never", "classes": "always", "modules": "always" } ` :
227259
228260::: incorrect
229261
230262``` js
231- /* eslint @stylistic/space-before-blocks: ["error", { "functions": "never", "keywords": "never", "classes": "always" }] */
263+ /* eslint @stylistic/space-before-blocks: ["error", { "functions": "never", "keywords": "never", "classes": "always", "modules": "always" }] */
232264
233265class Foo {
234266 constructor (){}
235267}
268+
269+ namespace Foo{
270+ bar: string
271+ }
236272```
237273
238274:::
239275
240- Examples of ** correct** code for this rule when configured ` { "functions": "never", "keywords": "never", "classes": "always" } ` :
276+ Examples of ** correct** code for this rule when configured ` { "functions": "never", "keywords": "never", "classes": "always", "modules": "always" } ` :
241277
242278::: correct
243279
244280``` js
245- /* eslint @stylistic/space-before-blocks: ["error", { "functions": "never", "keywords": "never", "classes": "always" }] */
281+ /* eslint @stylistic/space-before-blocks: ["error", { "functions": "never", "keywords": "never", "classes": "always", "modules": "always" }] */
246282
247283class Foo {
248284 constructor (){}
249285}
286+
287+ namespace Foo {
288+ bar: string
289+ }
250290```
251291
252292:::
0 commit comments