]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/arrow-spacing.md
bump version to 8.4.0-3
[pve-eslint.git] / eslint / docs / rules / arrow-spacing.md
1 # Require space before/after arrow function's arrow (arrow-spacing)
2
3 This rule normalize style of spacing before/after an arrow function's arrow(`=>`).
4
5 ```js
6 /*eslint-env es6*/
7
8 // { "before": true, "after": true }
9 (a) => {}
10
11 // { "before": false, "after": false }
12 (a)=>{}
13 ```
14
15 ## Rule Details
16
17 This rule takes an object argument with `before` and `after` properties, each with a Boolean value.
18
19 The default configuration is `{ "before": true, "after": true }`.
20
21 `true` means there should be **one or more spaces** and `false` means **no spaces**.
22
23 Examples of **incorrect** code for this rule with the default `{ "before": true, "after": true }` option:
24
25 ```js
26 /*eslint arrow-spacing: "error"*/
27 /*eslint-env es6*/
28
29 ()=> {};
30 () =>{};
31 (a)=> {};
32 (a) =>{};
33 a =>a;
34 a=> a;
35 ()=> {'\n'};
36 () =>{'\n'};
37 ```
38
39 Examples of **correct** code for this rule with the default `{ "before": true, "after": true }` option:
40
41 ```js
42 /*eslint arrow-spacing: "error"*/
43 /*eslint-env es6*/
44
45 () => {};
46 (a) => {};
47 a => a;
48 () => {'\n'};
49 ```
50
51 Examples of **incorrect** code for this rule with the `{ "before": false, "after": false }` option:
52
53 ```js
54 /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
55 /*eslint-env es6*/
56
57 () =>{};
58 (a) => {};
59 ()=> {'\n'};
60 ```
61
62 Examples of **correct** code for this rule with the `{ "before": false, "after": false }` option:
63
64 ```js
65 /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
66 /*eslint-env es6*/
67
68 ()=>{};
69 (a)=>{};
70 ()=>{'\n'};
71 ```
72
73 Examples of **incorrect** code for this rule with the `{ "before": false, "after": true }` option:
74
75 ```js
76 /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
77 /*eslint-env es6*/
78
79 () =>{};
80 (a) => {};
81 ()=>{'\n'};
82 ```
83
84 Examples of **correct** code for this rule with the `{ "before": false, "after": true }` option:
85
86 ```js
87 /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
88 /*eslint-env es6*/
89
90 ()=> {};
91 (a)=> {};
92 ()=> {'\n'};
93 ```