]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/block-spacing.md
first commit
[pve-eslint.git] / eslint / docs / rules / block-spacing.md
1 # Disallow or enforce spaces inside of blocks after opening block and before closing block (block-spacing)
2
3 ## Rule Details
4
5 This rule enforces consistent spacing inside an open block token and the next token on the same line. This rule also enforces consistent spacing inside a close block token and previous token on the same line.
6
7 ## Options
8
9 This rule has a string option:
10
11 * `"always"` (default) requires one or more spaces
12 * `"never"` disallows spaces
13
14 ### always
15
16 Examples of **incorrect** code for this rule with the default `"always"` option:
17
18 ```js
19 /*eslint block-spacing: "error"*/
20
21 function foo() {return true;}
22 if (foo) { bar = 0;}
23 function baz() {let i = 0;
24 return i;
25 }
26 ```
27
28 Examples of **correct** code for this rule with the default `"always"` option:
29
30 ```js
31 /*eslint block-spacing: "error"*/
32
33 function foo() { return true; }
34 if (foo) { bar = 0; }
35 ```
36
37 ### never
38
39 Examples of **incorrect** code for this rule with the `"never"` option:
40
41 ```js
42 /*eslint block-spacing: ["error", "never"]*/
43
44 function foo() { return true; }
45 if (foo) { bar = 0;}
46 ```
47
48 Examples of **correct** code for this rule with the `"never"` option:
49
50 ```js
51 /*eslint block-spacing: ["error", "never"]*/
52
53 function foo() {return true;}
54 if (foo) {bar = 0;}
55 ```
56
57 ## When Not To Use It
58
59 If you don't want to be notified about spacing style inside of blocks, you can safely disable this rule.