es6.js
6.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/**
* ES6
*/
'use strict';
module.exports = {
env: {
es6: true,
},
parserOptions: {
ecmaVersion: 6,
},
rules: {
/**
* This rule allows the use of braces around arrow function body, even if they can be omitted
* @see http://eslint.org/docs/rules/arrow-body-style
* @since 3.0.0
* @example
*
* ```js
* // correct
* let foo = () => {
* return 0;
* };
*
* let foo = () => {
* return {
* bar: {
* foo: 1,
* bar: 2,
* }
* };
* };
*
* let foo = () => 0;
*
* let foo = () => ({
* bar: {
* foo: 1,
* bar: 2,
* }
* });
** ```
*/
'arrow-body-style': 'off',
/**
* This rule disallows the use of parens when they are no required
* @see http://eslint.org/docs/rules/arrow-parens
*/
'arrow-parens': [ 'error', 'as-needed' ],
/**
* This rule normalize style of spacing before and after an arrow function's arrow(`=>`)
* @see http://eslint.org/docs/rules/arrow-spacing
*/
'arrow-spacing': [ 'error', { before: true, after: true }],
/**
* It doesn't check whether or not there is a valid `super()` call
* @see http://eslint.org/docs/rules/constructor-super
*/
'constructor-super': 'off',
/**
* This rule enforces spacing after the `*` of generator functions, but omitting before that
* @see http://eslint.org/docs/rules/generator-star-spacing
* @since 3.0.0
* @example
*
* ```js
* function* generator() {
* yield '44';
* yield '55';
* }
* ```
*/
'generator-star-spacing': [ 'error', { before: false, after: true }],
/**
* This rule disallows modifying variables of class declarations
* @see http://eslint.org/docs/rules/no-class-assign
*/
'no-class-assign': 'error',
/**
* Disallow arrow functions where they could be confused with comparisons
* @see http://eslint.org/docs/rules/no-confusing-arrow
* @example
*
* ```js
* var x = a => 1 ? 2 : 3; // incorrect
* var x = a => (1 ? 2 : 3); // correct
* ````
*/
'no-confusing-arrow': [ 'error', {
allowParens: true,
}],
/**
* Disallow modifying variables that are declared using `const`
* @see http://eslint.org/docs/rules/no-const-assign
*/
'no-const-assign': 'error',
/**
* Disallow duplicate name in class members
* @see http://eslint.org/docs/rules/no-dupe-class-members
*/
'no-dupe-class-members': 'error',
/**
* allow Symbol Constructor
* @see http://eslint.org/docs/rules/no-new-symbol
*/
'no-new-symbol': 'off',
/**
* Disallow use of this/super before calling super() in constructors
* @see http://eslint.org/docs/rules/no-this-before-super
* @since 3.0.0
*/
'no-this-before-super': 'error',
/**
* Disallow unnecessary computed property keys on objects
* @see http://eslint.org/docs/rules/no-useless-computed-key
* @example
*
* ```js
* foo = { ['a' + 'b']: 'foo' }; // correct
* foo = { ['a']: 'bar' }; // incorrect
* ```
*/
'no-useless-computed-key': 'error',
/**
* Disallow unnecessary constructor
* @see http://eslint.org/docs/rules/no-useless-constructor
*/
'no-useless-constructor': 'error',
/**
* require `let` or `const` instead of `var`
* @see http://eslint.org/docs/rules/no-var
*/
'no-var': 'error',
/**
* Require Object Literal Shorthand Syntax
* @see http://eslint.org/docs/rules/object-shorthand
* @since 3.0.0
* @example
*
* ```js
* // correct
* // properties
* const foo = { x, y, z };
*
* // methods
* const foo = {
* a() {},
* b() {}
* };
*
* const bar = {
* ConstructorFunction: function() {}
* };
*
* // incorrect
* const foo = {
* 'a-b'() {}
* };
* ```
*/
'object-shorthand': [ 'error', 'always', {
avoidQuotes: true,
ignoreConstructors: false,
}],
/**
* If a variable is never reassigned, using the `const` declaration is better
* @see http://eslint.org/docs/rules/prefer-const
* @since 3.0.0
* @example
*
* 1. Specially, if all variables in destructuring should be `const`,
* this rule warns the variables
*
* ```js
* // incorrect
* let { a, b } = obj;
* console.log(a, b);
*
* // correct
* let { a, b } = obj;
* a = a + 1;
* console.log(a, b);
* ```
*/
'prefer-const': [ 'error', {
destructuring: 'all',
ignoreReadBeforeAssign: true,
}],
/**
* This rule doesn't prefer using Reflect methods where applicable
* @see http://eslint.org/docs/rules/prefer-reflect
*/
'prefer-reflect': 'off',
/**
* This rule doesn't prefer using the rest parameters instead of `arguments`
* @see http://eslint.org/docs/rules/prefer-rest-params
* @since 3.0.0
*/
'prefer-rest-params': 'off',
/**
* This rule doesn't prefer using the spread operator instead of `.apply()`
* @see http://eslint.org/docs/rules/prefer-spread
*/
'prefer-spread': 'off',
/**
* Suggest using template syntax instead of string concat
* @see http://eslint.org/docs/rules/prefer-template
*/
'prefer-template': 'off',
/**
* This rule doesn't require a valid `yield` in generator functions
* @see http://eslint.org/docs/rules/require-yield
*/
'require-yield': 'off',
/**
* This rule disallows usage of spacing in template strings
* @see http://eslint.org/docs/rules/template-curly-spacing
* @example
*
* ```js
* // incorrect
* `${ bar }`;
* `hello, ${ people.name}!`;
* `hello, ${people.name }!`;
*
* // correct
* `${bar}`;
* `hello, ${people.name}!`;
*
* // specially, this is correct
* `${
* bar
* }`;
* ```
*/
'template-curly-spacing': 'error',
/**
* Enforce spacing after the `*` in `yield*` expressions
* @see http://eslint.org/docs/rules/yield-star-spacing
*/
'yield-star-spacing': [ 'error', { before: false, after: true }],
/**
* only pass instances of the built-in Error object to the reject() function
* @see https://eslint.org/docs/rules/prefer-promise-reject-errors
*/
'prefer-promise-reject-errors': 'error',
},
};