@@ -15,8 +15,6 @@ be wrapped in parentheses. This rule enforces the consistent use of parentheses
15
15
This rule enforces parentheses around arrow function parameters regardless of arity. For example:
16
16
17
17
``` js
18
- /* eslint-env es6*/
19
-
20
18
// Bad
21
19
a => {}
22
20
@@ -28,8 +26,6 @@ Following this style will help you find arrow functions (`=>`) which may be mist
28
26
when a comparison such as ` >= ` was the intent.
29
27
30
28
``` js
31
- /* eslint-env es6*/
32
-
33
29
// Bad
34
30
if (a => 2 ) {
35
31
}
@@ -42,8 +38,6 @@ if (a >= 2) {
42
38
The rule can also be configured to discourage the use of parens when they are not required:
43
39
44
40
``` js
45
- /* eslint-env es6*/
46
-
47
41
// Bad
48
42
(a ) => {}
49
43
@@ -72,7 +66,6 @@ Examples of **incorrect** code for this rule with the default `"always"` option:
72
66
73
67
``` js
74
68
/* eslint arrow-parens: ["error", "always"]*/
75
- /* eslint-env es6*/
76
69
77
70
a => {};
78
71
a => a;
@@ -90,7 +83,6 @@ Examples of **correct** code for this rule with the default `"always"` option:
90
83
91
84
``` js
92
85
/* eslint arrow-parens: ["error", "always"]*/
93
- /* eslint-env es6*/
94
86
95
87
() => {};
96
88
(a ) => {};
@@ -107,8 +99,6 @@ a.then((foo) => { if (true) {} });
107
99
One of the benefits of this option is that it prevents the incorrect use of arrow functions in conditionals:
108
100
109
101
``` js
110
- /* eslint-env es6*/
111
-
112
102
var a = 1 ;
113
103
var b = 2 ;
114
104
// ...
@@ -125,8 +115,6 @@ The contents of the `if` statement is an arrow function, not a comparison.
125
115
If the arrow function is intentional, it should be wrapped in parens to remove ambiguity.
126
116
127
117
``` js
128
- /* eslint-env es6*/
129
-
130
118
var a = 1 ;
131
119
var b = 0 ;
132
120
// ...
@@ -141,8 +129,6 @@ if ((a) => b) {
141
129
The following is another example of this behavior:
142
130
143
131
``` js
144
- /* eslint-env es6*/
145
-
146
132
var a = 1 , b = 2 , c = 3 , d = 4 ;
147
133
var f = a => b ? c: d;
148
134
// f = ?
@@ -153,8 +139,6 @@ var f = a => b ? c: d;
153
139
This should be rewritten like so:
154
140
155
141
``` js
156
- /* eslint-env es6*/
157
-
158
142
var a = 1 , b = 2 , c = 3 , d = 4 ;
159
143
var f = (a ) => b ? c: d;
160
144
```
@@ -167,7 +151,6 @@ Examples of **incorrect** code for this rule with the `"as-needed"` option:
167
151
168
152
``` js
169
153
/* eslint arrow-parens: ["error", "as-needed"]*/
170
- /* eslint-env es6*/
171
154
172
155
(a ) => {};
173
156
(a ) => a;
@@ -188,7 +171,6 @@ Examples of **correct** code for this rule with the `"as-needed"` option:
188
171
189
172
``` js
190
173
/* eslint arrow-parens: ["error", "as-needed"]*/
191
- /* eslint-env es6*/
192
174
193
175
() => {};
194
176
a => {};
@@ -215,7 +197,6 @@ Examples of **incorrect** code for the `{ "requireForBlockBody": true }` option:
215
197
216
198
``` js
217
199
/* eslint arrow-parens: [2, "as-needed", { "requireForBlockBody": true }]*/
218
- /* eslint-env es6*/
219
200
220
201
(a ) => a;
221
202
a => {};
@@ -235,7 +216,6 @@ Examples of **correct** code for the `{ "requireForBlockBody": true }` option:
235
216
236
217
``` js
237
218
/* eslint arrow-parens: [2, "as-needed", { "requireForBlockBody": true }]*/
238
- /* eslint-env es6*/
239
219
240
220
(a ) => {};
241
221
(a ) => {' \n ' };
0 commit comments