UNPKG

11.2 kBJavaScriptView Raw
1'use strict';
2
3module.exports = {
4 parserOptions: {
5 ecmaVersion: 2021,
6 sourceType: 'module',
7 ecmaFeatures: {
8 jsx: true
9 }
10 },
11 env: {
12 es2021: true,
13 node: true
14 },
15 reportUnusedDisableDirectives: true,
16 rules: {
17 'comma-dangle': [
18 'error',
19 'never'
20 ],
21 'for-direction': 'error',
22 'getter-return': 'error',
23 'no-async-promise-executor': 'error',
24 'no-await-in-loop': 'error',
25 'no-compare-neg-zero': 'error',
26 'no-cond-assign': 'error',
27 'no-constant-condition': 'error',
28 'no-control-regex': 'error',
29 'no-debugger': 'error',
30 'no-dupe-args': 'error',
31 'no-dupe-else-if': 'error',
32 'no-dupe-keys': 'error',
33 'no-duplicate-case': 'error',
34 'no-empty-character-class': 'error',
35 'no-empty': [
36 'error',
37 {
38 allowEmptyCatch: true
39 }
40 ],
41 'no-ex-assign': 'error',
42 'no-extra-boolean-cast': 'error',
43 // Disabled because of https://github.com/eslint/eslint/issues/6028
44 // 'no-extra-parens': [
45 // 'error',
46 // 'all',
47 // {
48 // conditionalAssign: false,
49 // nestedBinaryExpressions: false,
50 // ignoreJSX: 'multi-line'
51 // }
52 // ],
53 'no-extra-semi': 'error',
54 'no-func-assign': 'error',
55 'no-import-assign': 'error',
56 'no-inner-declarations': 'error',
57 'no-invalid-regexp': 'error',
58 'no-irregular-whitespace': 'error',
59 'no-loss-of-precision': 'error',
60 'no-misleading-character-class': 'error',
61 'no-obj-calls': 'error',
62 'no-promise-executor-return': 'error',
63 'no-prototype-builtins': 'error',
64 'no-regex-spaces': 'error',
65 'no-setter-return': 'error',
66 'no-sparse-arrays': 'error',
67 'no-template-curly-in-string': 'error',
68 'no-unreachable': 'error',
69 'no-unreachable-loop': 'error',
70 'no-unsafe-finally': 'error',
71 'no-unsafe-negation': 'error',
72 'no-unsafe-optional-chaining': [
73 'error',
74 {
75 disallowArithmeticOperators: true
76 }
77 ],
78 'no-useless-backreference': 'error',
79 'use-isnan': 'error',
80 'valid-typeof': [
81 'error',
82 {
83 requireStringLiterals: false
84 }
85 ],
86 'no-unexpected-multiline': 'error',
87 'accessor-pairs': [
88 'error',
89 {
90 enforceForClassMembers: true
91 }
92 ],
93 'array-callback-return': [
94 'error',
95 {
96 allowImplicit: true
97 }
98 ],
99 'block-scoped-var': 'error',
100 complexity: 'warn',
101 curly: 'error',
102 'default-case': 'error',
103 'default-case-last': 'error',
104 'default-param-last': 'error',
105 'dot-notation': 'error',
106 'dot-location': [
107 'error',
108 'property'
109 ],
110 eqeqeq: 'error',
111 'grouped-accessor-pairs': [
112 'error',
113 'getBeforeSet'
114 ],
115 'guard-for-in': 'error',
116 'no-alert': 'error',
117 'no-caller': 'error',
118 'no-case-declarations': 'error',
119 'no-constructor-return': 'error',
120 'no-else-return': [
121 'error',
122 {
123 allowElseIf: false
124 }
125 ],
126 'no-empty-pattern': 'error',
127 'no-eq-null': 'error',
128 'no-eval': 'error',
129 'no-extend-native': 'error',
130 'no-extra-bind': 'error',
131 'no-extra-label': 'error',
132 'no-fallthrough': 'error',
133 'no-floating-decimal': 'error',
134 'no-global-assign': 'error',
135 'no-implicit-coercion': 'error',
136 'no-implicit-globals': 'error',
137 'no-implied-eval': 'error',
138 'no-iterator': 'error',
139 'no-labels': 'error',
140 'no-lone-blocks': 'error',
141 'no-multi-spaces': 'error',
142 'no-multi-str': 'error',
143 'no-new-func': 'error',
144 'no-new-wrappers': 'error',
145 'no-nonoctal-decimal-escape': 'error',
146 'no-new': 'error',
147 'no-octal-escape': 'error',
148 'no-octal': 'error',
149 'no-proto': 'error',
150 'no-redeclare': 'error',
151 'no-return-assign': [
152 'error',
153 'always'
154 ],
155 'no-return-await': 'error',
156 'no-script-url': 'error',
157 'no-self-assign': [
158 'error',
159 {
160 props: true
161 }
162 ],
163 'no-self-compare': 'error',
164 'no-sequences': 'error',
165 'no-throw-literal': 'error',
166 'no-unmodified-loop-condition': 'error',
167 'no-unused-expressions': [
168 'error',
169 {
170 enforceForJSX: true
171 }
172 ],
173 'no-unused-labels': 'error',
174 'no-useless-call': 'error',
175 'no-useless-catch': 'error',
176 'no-useless-concat': 'error',
177 'no-useless-escape': 'error',
178 'no-useless-return': 'error',
179 'no-void': 'error',
180 'no-warning-comments': 'warn',
181 'no-with': 'error',
182
183 // Disabled for now as Firefox doesn't support named capture groups and I'm tired of getting issues about the use of named capture groups...
184 // 'prefer-named-capture-group': 'error'
185
186 'prefer-promise-reject-errors': [
187 'error',
188 {
189 allowEmptyReject: true
190 }
191 ],
192 'prefer-regex-literals': 'error',
193 radix: 'error',
194
195 // Disabled for now as it causes too much churn
196 // TODO: Enable it in the future when I have time to deal with
197 // the churn and the rule is stable and has an autofixer.
198 // Still doesn't have a fixer as of ESLint 7.24.0.
199 // 'require-unicode-regexp': 'error',
200
201 'wrap-iife': [
202 'error',
203 'inside',
204 {
205 functionPrototypeMethods: true
206 }
207 ],
208 yoda: 'error',
209 'no-delete-var': 'error',
210 'no-label-var': 'error',
211 'no-restricted-globals': [
212 'error',
213 'event'
214 ],
215 'no-shadow-restricted-names': 'error',
216 'no-undef-init': 'error',
217 'no-undef': [
218 'error',
219 {
220 typeof: true
221 }
222 ],
223 'no-unused-vars': [
224 'error',
225 {
226 vars: 'all',
227 args: 'after-used',
228 ignoreRestSiblings: true,
229 argsIgnorePattern: /^_/.source,
230 caughtErrors: 'all',
231 caughtErrorsIgnorePattern: /^_$/.source
232 }
233 ],
234 'no-buffer-constructor': 'error',
235 'no-restricted-imports': [
236 'error',
237 'domain',
238 'freelist',
239 'smalloc',
240 'punycode',
241 'sys',
242 'querystring',
243 'colors'
244 ],
245 'array-bracket-newline': [
246 'error',
247 'consistent'
248 ],
249 'array-bracket-spacing': [
250 'error',
251 'never'
252 ],
253 'array-element-newline': [
254 'error',
255 'consistent'
256 ],
257 'brace-style': [
258 'error',
259 '1tbs',
260 {
261 allowSingleLine: false
262 }
263 ],
264 camelcase: [
265 'error',
266 {
267 properties: 'always'
268 }
269 ],
270 'capitalized-comments': [
271 'error',
272 'always',
273 {
274 // You can also ignore this rule by wrapping the first word in quotes.
275 // c8 => https://github.com/bcoe/c8
276 ignorePattern: /pragma|ignore|prettier-ignore|webpack\w+:|c8/.source,
277 ignoreInlineComments: true,
278 ignoreConsecutiveComments: true
279 }
280 ],
281 'comma-spacing': [
282 'error',
283 {
284 before: false,
285 after: true
286 }
287 ],
288 'comma-style': [
289 'error',
290 'last'
291 ],
292 'computed-property-spacing': [
293 'error',
294 'never',
295 {
296 enforceForClassMembers: true
297 }
298 ],
299 'eol-last': 'error',
300 'func-call-spacing': [
301 'error',
302 'never'
303 ],
304 'func-name-matching': [
305 'error',
306 {
307 considerPropertyDescriptor: true
308 }
309 ],
310 'func-names': [
311 'error',
312 'never'
313 ],
314 'function-call-argument-newline': [
315 'error',
316 'consistent'
317 ],
318 indent: [
319 'error',
320 'tab',
321 {
322 SwitchCase: 1
323 }
324 ],
325 'jsx-quotes': 'error',
326 'key-spacing': [
327 'error',
328 {
329 beforeColon: false,
330 afterColon: true
331 }
332 ],
333 'keyword-spacing': 'error',
334 'linebreak-style': [
335 process.platform === 'win32' ? 'off' : 'error',
336 'unix'
337 ],
338 'lines-between-class-members': [
339 'error',
340 'always',
341 {
342 // Workaround to allow class fields to not have lines between them.
343 // TODO: Get ESLint to add an option to ignore class fields.
344 exceptAfterSingleLine: true
345 }
346 ],
347 'max-depth': 'warn',
348 'max-nested-callbacks': [
349 'warn',
350 4
351 ],
352 'max-params': [
353 'warn',
354 {
355 max: 4
356 }
357 ],
358 'max-statements-per-line': 'error',
359 'new-cap': [
360 'error',
361 {
362 newIsCap: true,
363 capIsNew: true
364 }
365 ],
366 'new-parens': 'error',
367 'no-array-constructor': 'error',
368 'no-lonely-if': 'error',
369 'no-mixed-operators': 'error',
370 'no-mixed-spaces-and-tabs': 'error',
371 'no-multi-assign': 'error',
372 'no-multiple-empty-lines': [
373 'error',
374 {
375 max: 1
376 }
377 ],
378 'no-negated-condition': 'error',
379 'no-new-object': 'error',
380 'no-whitespace-before-property': 'error',
381 'no-trailing-spaces': 'error',
382 'no-unneeded-ternary': 'error',
383 'object-curly-spacing': [
384 'error',
385 'never'
386 ],
387 // Disabled because of https://github.com/xojs/eslint-config-xo/issues/27
388 // 'object-property-newline': 'error',
389 'one-var': [
390 'error',
391 'never'
392 ],
393 'one-var-declaration-per-line': 'error',
394 'operator-assignment': [
395 'error',
396 'always'
397 ],
398 'operator-linebreak': [
399 'error',
400 'after'
401 ],
402 'padded-blocks': [
403 'error',
404 'never',
405 {
406 allowSingleLineBlocks: false
407 }
408 ],
409 'padding-line-between-statements': [
410 'error',
411 {
412 blankLine: 'always',
413 prev: 'multiline-block-like',
414 next: '*'
415 }
416 ],
417 'prefer-exponentiation-operator': 'error',
418 'prefer-object-spread': 'error',
419 'quote-props': [
420 'error',
421 'as-needed'
422 ],
423 quotes: [
424 'error',
425 'single'
426 ],
427 'semi-spacing': [
428 'error',
429 {
430 before: false,
431 after: true
432 }
433 ],
434 'semi-style': [
435 'error',
436 'last'
437 ],
438 semi: [
439 'error',
440 'always'
441 ],
442 'space-before-blocks': [
443 'error',
444 'always'
445 ],
446 'space-before-function-paren': [
447 'error',
448 {
449 anonymous: 'always',
450 named: 'never',
451 asyncArrow: 'always'
452 }
453 ],
454 'space-in-parens': [
455 'error',
456 'never'
457 ],
458 'space-infix-ops': 'error',
459 'space-unary-ops': 'error',
460 'spaced-comment': [
461 'error',
462 'always',
463 {
464 line: {
465 exceptions: [
466 '-',
467 '+',
468 '*'
469 ],
470 markers: [
471 '!',
472 '/',
473 '=>'
474 ]
475 },
476 block: {
477 exceptions: [
478 '-',
479 '+',
480 '*'
481 ],
482 markers: [
483 '!',
484 '*'
485 ],
486 balanced: true
487 }
488 }
489 ],
490 'switch-colon-spacing': [
491 'error',
492 {
493 after: true,
494 before: false
495 }
496 ],
497 'template-tag-spacing': [
498 'error',
499 'never'
500 ],
501 'unicode-bom': [
502 'error',
503 'never'
504 ],
505 'arrow-parens': [
506 'error',
507 'as-needed'
508 ],
509 'arrow-spacing': [
510 'error',
511 {
512 before: true,
513 after: true
514 }
515 ],
516 'constructor-super': 'error',
517 'generator-star-spacing': [
518 'error',
519 'both'
520 ],
521 'no-class-assign': 'error',
522 'no-const-assign': 'error',
523 'no-dupe-class-members': 'error',
524 'no-new-symbol': 'error',
525 'no-this-before-super': 'error',
526 'no-useless-computed-key': [
527 'error',
528 {
529 enforceForClassMembers: true
530 }
531 ],
532 'no-useless-constructor': 'error',
533 'no-useless-rename': 'error',
534 'no-var': 'error',
535 'object-shorthand': [
536 'error',
537 'always'
538 ],
539 'prefer-arrow-callback': [
540 'error',
541 {
542 allowNamedFunctions: true
543 }
544 ],
545 'prefer-const': [
546 'error',
547 {
548 destructuring: 'all'
549 }
550 ],
551 'prefer-destructuring': [
552 'error',
553 {
554 // `array` is disabled because it forces destructuring on
555 // stupid stuff like `foo.bar = process.argv[2];`
556 // TODO: Open ESLint issue about this
557 VariableDeclarator: {
558 array: false,
559 object: true
560 },
561 AssignmentExpression: {
562 array: false,
563
564 // Disabled because object assignment destructuring requires parens wrapping:
565 // `let foo; ({foo} = object);`
566 object: false
567 }
568 },
569 {
570 enforceForRenamedProperties: false
571 }
572 ],
573 'prefer-numeric-literals': 'error',
574 'prefer-rest-params': 'error',
575 'prefer-spread': 'error',
576 'require-yield': 'error',
577 'rest-spread-spacing': [
578 'error',
579 'never'
580 ],
581 'symbol-description': 'error',
582 'template-curly-spacing': 'error',
583 'yield-star-spacing': [
584 'error',
585 'both'
586 ]
587 }
588};