UNPKG

19.4 kBJavaScriptView Raw
1// @flow
2// eslint-disable-next-line import/no-commonjs
3module.exports = {
4 parser: 'babel-eslint',
5 env: {
6 browser: true,
7 es6: true,
8 node: true,
9 jasmine: true,
10 },
11 globals: {
12 __DEV__: true,
13 },
14 parserOptions: {
15 ecmaVersion: 2017,
16 sourceType: 'module',
17 },
18 plugins: [
19 'babel',
20 'cumul8',
21 'flowtype',
22 'import',
23 'jasmine',
24 'json',
25 'jsx-a11y',
26 'promise',
27 'react',
28 ],
29 rules: {
30 // ERRORS
31
32 'accessor-pairs': 'error',
33 'array-bracket-spacing': ['error', 'never'],
34 'arrow-parens': ['error', 'always'],
35 'arrow-spacing': ['error', {before: true, after: true}],
36 'babel/object-curly-spacing': ['error', 'never'],
37 'babel/semi': ['error', 'always'],
38 'block-scoped-var': 'error',
39 'block-spacing': ['error', 'always'],
40 'brace-style': ['error', '1tbs', {allowSingleLine: true}],
41 'comma-dangle': ['error', {
42 arrays: 'always-multiline',
43 objects: 'always-multiline',
44 imports: 'always-multiline',
45 exports: 'always-multiline',
46 functions: 'never',
47 }],
48 'comma-spacing': ['error', {before: false, after: true}],
49 'comma-style': ['error', 'last'],
50 'computed-property-spacing': ['error', 'never'],
51 'consistent-return': 'error',
52 'consistent-this': 'error',
53 'constructor-super': 'error',
54 'cumul8/alphabetical-destructuring': 'error',
55 'cumul8/alphabetical-stylesheets': 'error',
56 'cumul8/inefficient-for-each': 'error',
57 'cumul8/inefficient-for-loop': 'error',
58 'dot-location': ['error', 'property'],
59 'dot-notation': 'error',
60 'eol-last': ['error', 'always'],
61 eqeqeq: ['error', 'allow-null'],
62 'flowtype/boolean-style': ['error', 'boolean'],
63 'flowtype/delimiter-dangle': ['error', 'always-multiline'],
64 'flowtype/generic-spacing': ['error', 'never'],
65 'flowtype/no-dupe-keys': 'error',
66 'flowtype/no-primitive-constructor-types': 'error',
67 'flowtype/no-types-missing-file-annotation': 'error',
68 'flowtype/no-unused-expressions': 'error',
69 'flowtype/no-weak-types': ['error', {
70 any: false,
71 Object: true,
72 Function: true,
73 }],
74 'flowtype/object-type-delimiter': ['error', 'comma'],
75 'flowtype/require-variable-type': 'off',
76 'flowtype/semi': ['error', 'always'],
77 'flowtype/sort-keys': ['error', 'asc', {
78 caseSensitive: false,
79 natural: true,
80 }],
81 'flowtype/space-after-type-colon': ['error', 'always'],
82 'flowtype/space-before-generic-bracket': ['error', 'never'],
83 'flowtype/space-before-type-colon': ['error', 'never'],
84 'flowtype/type-id-match': ['error', '^([A-Z][a-z0-9]+)+Type$'],
85 'flowtype/union-intersection-spacing': ['error', 'always'],
86 'for-direction': 'error',
87 'func-call-spacing': ['error', 'never'],
88 'func-name-matching': 'error',
89 'func-style': ['error', 'expression'],
90 'generator-star-spacing': ['error', {before: false, after: true}],
91 'getter-return': 'error',
92 'guard-for-in': 'error',
93 'import/no-absolute-path': 'error',
94 'import/default': 'error',
95 'import/export': 'error',
96 'import/extensions': ['error', 'never'],
97 'import/imports-first': 'error',
98 'import/named': 'error',
99 'import/namespace': 'error',
100 'import/newline-after-import': 'error',
101 'import/no-amd': 'error',
102 'import/no-commonjs': 'error',
103 'import/no-deprecated': 'error',
104 'import/no-duplicates': 'error',
105 'import/no-mutable-exports': 'error',
106 'import/no-named-as-default-member': 'error',
107 'import/no-named-default': 'error',
108 'import/no-namespace': 'error',
109 'import/no-unresolved': 'error',
110 'import/prefer-default-export': 'error',
111 indent: ['error', 'tab', {SwitchCase: 1}],
112 'jasmine/expect-matcher': 'error',
113 'jasmine/expect-single-argument': 'error',
114 'jasmine/no-expect-in-setup-teardown': 'error',
115 'jasmine/no-focused-tests': 'error',
116 'jasmine/no-global-setup': 'error',
117 'jasmine/no-suite-dupes': 'error',
118 'jasmine/no-spec-dupes': ['error', 'branch'],
119 'jasmine/missing-expect': 'error',
120 'jasmine/no-suite-callback-args': 'error',
121 'jasmine/no-unsafe-spy': 'error',
122 'jasmine/prefer-jasmine-matcher': 'error',
123 'jsx-a11y/accessible-emoji': 'error',
124 'jsx-a11y/alt-text': 'error',
125 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
126 'jsx-a11y/anchor-has-content': 'error',
127 'jsx-a11y/anchor-is-valid': 'error',
128 'jsx-a11y/aria-props': 'error',
129 'jsx-a11y/aria-proptypes': 'error',
130 'jsx-a11y/aria-role': 'error',
131 'jsx-a11y/aria-unsupported-elements': 'error',
132 'jsx-a11y/heading-has-content': 'error',
133 'jsx-a11y/html-has-lang': 'error',
134 'jsx-a11y/iframe-has-title': 'error',
135 'jsx-a11y/img-redundant-alt': 'error',
136 'jsx-a11y/interactive-supports-focus': 'error',
137 'jsx-a11y/lang': 'error',
138 'jsx-a11y/media-has-caption': 'error',
139 'jsx-a11y/mouse-events-have-key-events': 'error',
140 'jsx-a11y/no-access-key': 'error',
141 'jsx-a11y/no-distracting-elements': 'error',
142 'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error',
143 'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error',
144 'jsx-a11y/no-noninteractive-tabindex': 'error',
145 'jsx-a11y/no-onchange': 'error',
146 'jsx-a11y/no-redundant-roles': 'error',
147 'jsx-a11y/no-static-element-interactions': 'error',
148 'jsx-a11y/role-has-required-aria-props': 'error',
149 'jsx-a11y/role-supports-aria-props': 'error',
150 'jsx-a11y/scope': 'error',
151 'jsx-a11y/tabindex-no-positive': 'error',
152 'jsx-quotes': ['error', 'prefer-single'],
153 'key-spacing': ['error', {mode: 'strict', beforeColon: false, afterColon: true}],
154 'keyword-spacing': ['error', {before: true, after: true, overrides: {}}],
155 'lines-between-class-members': ['error', 'always'],
156 'max-depth': ['error', 3],
157 'max-len': ['error', 150, 4],
158 'max-lines': ['error', {max: 1000, skipBlankLines: false, skipComments: true}],
159 'max-nested-callbacks': ['error', 5],
160 'max-params': ['error', 4],
161 'max-statements': ['error', 100],
162 'max-statements-per-line': ['error', {max: 2}],
163 'newline-per-chained-call': ['error', {ignoreChainWithDepth: 3}],
164 'new-parens': 'error',
165 'no-alert': 'error',
166 'no-array-constructor': 'error',
167 'no-await-in-loop': 'error',
168 'no-bitwise': 'error',
169 'no-buffer-constructor': 'error',
170 'no-caller': 'error',
171 'no-catch-shadow': 'error',
172 'no-class-assign': 'error',
173 'no-compare-neg-zero': 'error',
174 'no-cond-assign': 'error',
175 'no-const-assign': 'error',
176 'no-constant-condition': 'error',
177 'no-control-regex': 'error',
178 'no-debugger': 'error',
179 'no-delete-var': 'error',
180 'no-div-regex': 'error',
181 'no-dupe-args': 'error',
182 'no-dupe-class-members': 'error',
183 'no-dupe-keys': 'error',
184 'no-duplicate-case': 'error',
185 'no-duplicate-imports': 'error',
186 'no-else-return': 'error',
187 'no-empty': 'error',
188 'no-empty-character-class': 'error',
189 'no-empty-pattern': 'error',
190 'no-eval': 'error',
191 'no-ex-assign': 'error',
192 'no-extend-native': 'error',
193 'no-extra-bind': 'error',
194 'no-extra-boolean-cast': 'error',
195 'no-extra-semi': 'error',
196 'no-fallthrough': 'error',
197 'no-floating-decimal': 'error',
198 'no-func-assign': 'error',
199 'no-global-assign': 'error',
200 'no-implicit-coercion': ['error', {boolean: true, number: true, string: true}],
201 'no-implicit-globals': 'error',
202 'no-implied-eval': 'error',
203 'no-inline-comments': 'error',
204 'no-inner-declarations': 'error',
205 'no-invalid-regexp': 'error',
206 'no-irregular-whitespace': 'error',
207 'no-iterator': 'error',
208 'no-labels': 'error',
209 'no-label-var': 'error',
210 'no-lone-blocks': 'error',
211 'no-lonely-if': 'error',
212 'no-loop-func': 'error',
213 'no-mixed-spaces-and-tabs': 'error',
214 'no-multi-assign': 'error',
215 'no-multi-spaces': 'error',
216 'no-multi-str': 'error',
217 'no-multiple-empty-lines': 'error',
218 'no-nested-ternary': 'error',
219 'no-new': 'error',
220 'no-new-func': 'error',
221 'no-new-object': 'error',
222 'no-new-symbol': 'error',
223 'no-new-wrappers': 'error',
224 'no-octal': 'error',
225 'no-octal-escape': 'error',
226 'no-obj-calls': 'error',
227 'no-process-env': 'error',
228 'no-proto': 'error',
229 'no-prototype-builtins': 'error',
230 'no-redeclare': 'error',
231 'no-regex-spaces': 'error',
232 'no-return-assign': 'error',
233 'no-return-await': 'error',
234 'no-script-url': 'error',
235 'no-self-assign': 'error',
236 'no-self-compare': 'error',
237 'no-sequences': 'error',
238 'no-shadow-restricted-names': 'error',
239 'no-sparse-arrays': 'error',
240 'no-template-curly-in-string': 'error',
241 'no-this-before-super': 'error',
242 'no-throw-literal': 'error',
243 'no-trailing-spaces': ['error', {skipBlankLines: false}],
244 'no-undef': 'error',
245 'no-undef-init': 'error',
246 'no-unexpected-multiline': 'error',
247 'no-unmodified-loop-condition': 'error',
248 'no-unreachable': 'error',
249 'no-unsafe-finally': 'error',
250 'no-unsafe-negation': 'error',
251 'no-unused-expressions': 'error',
252 'no-unused-vars': ['error', {args: 'none'}],
253 'no-useless-computed-key': 'error',
254 'no-useless-constructor': 'error',
255 'no-useless-escape': 'error',
256 'no-useless-rename': ['error', {
257 ignoreDestructuring: false,
258 ignoreImport: false,
259 ignoreExport: false,
260 }],
261 'no-var': 'error',
262 'no-void': 'error',
263 'no-whitespace-before-property': 'error',
264 'no-with': 'error',
265 'object-shorthand': 'error',
266 'one-var-declaration-per-line': 'error',
267 'operator-assignment': ['error', 'always'],
268 'operator-linebreak': ['error', 'after'],
269 'padding-line-between-statements': [
270 'error',
271 {blankLine: 'always', prev: ['directive'], next: '*'},
272 {blankLine: 'never', prev: ['directive'], next: ['directive']},
273 ],
274 'prefer-arrow-callback': 'error',
275 'prefer-const': 'error',
276 'prefer-numeric-literals': 'error',
277 'prefer-promise-reject-errors': 'error',
278 'prefer-spread': 'error',
279 'prefer-template': 'error',
280 'promise/always-return': 'error',
281 'promise/catch-or-return': ['error', {terminationMethod: ['catch', 'finally']}],
282 'promise/no-return-wrap': 'error',
283 'promise/no-native': 'error',
284 'promise/no-promise-in-callback': 'error',
285 'promise/no-return-in-finally': 'error',
286 'promise/param-names': 'error',
287 quotes: ['error', 'single', {allowTemplateLiterals: true}],
288 'quote-props': ['error', 'as-needed'],
289 radix: 'error',
290 'react/default-props-match-prop-types': ['error', {allowRequiredDefaults: true}],
291 'react/display-name': ['error', {ignoreTranspilerName: true}],
292 'react/forbid-foreign-prop-types': 'error',
293 'react/forbid-prop-types': ['error', {forbid: ['any', 'array', 'object']}],
294 'react/jsx-boolean-value': ['error', 'always'],
295 'react/jsx-closing-bracket-location': ['error', {location: 'after-props'}],
296 'react/jsx-closing-tag-location': 'error',
297 'react/jsx-curly-spacing': ['error', 'never'],
298 'react/jsx-equals-spacing': ['error', 'never'],
299 'react/jsx-indent-props': ['error', 'tab'],
300 'react/jsx-indent': ['error', 'tab'],
301 'react/jsx-key': 'error',
302 'react/jsx-max-props-per-line': ['error', {maximum: 4}],
303 'react/jsx-no-comment-textnodes': 'error',
304 'react/jsx-no-duplicate-props': ['error', {ignoreCase: true}],
305 'react/jsx-no-undef': ['error', {allowGlobals: true}],
306 'react/jsx-no-target-blank': 'error',
307 'react/jsx-pascal-case': 'error',
308 'react/jsx-sort-props': 'error',
309 'react/jsx-tag-spacing': ['error', {
310 afterOpening: 'never',
311 beforeSelfClosing: 'always',
312 closingSlash: 'never',
313 }],
314 'react/jsx-uses-react': 'error',
315 'react/jsx-uses-vars': 'error',
316 'react/jsx-wrap-multilines': 'error',
317 'react/no-children-prop': 'error',
318 'react/no-multi-comp': ['error', {ignoreStateless: true}],
319 'react/no-danger': 'error',
320 'react/no-danger-with-children': 'error',
321 'react/no-deprecated': 'error',
322 'react/no-did-mount-set-state': 'error',
323 'react/no-did-update-set-state': 'error',
324 'react/no-direct-mutation-state': 'error',
325 'react/no-is-mounted': 'error',
326 'react/no-redundant-should-component-update': 'error',
327 'react/no-render-return-value': 'error',
328 'react/no-typos': 'error',
329 'react/no-will-update-set-state': 'error',
330 'react/no-unescaped-entities': 'error',
331 'react/no-unknown-property': 'error',
332 'react/no-unused-state': 'error',
333 'react/prefer-es6-class': 'error',
334 'react/prop-types': ['error', {ignore: [
335 'aria-label',
336 'className',
337 'children',
338 'id',
339 'onClick',
340 'style',
341 ]}],
342 'react/react-in-jsx-scope': 'error',
343 'react/require-optimization': 'error',
344 'react/require-render-return': 'error',
345 'react/self-closing-comp': ['error', {component: true, html: true}],
346 'react/sort-comp': ['error', {
347 order: [
348 'lifecycle',
349 'render',
350 'everything-else',
351 ],
352 groups: {
353 lifecycle: [
354 'displayName',
355 'mixins',
356 'type-annotations',
357 'propTypes',
358 'contextTypes',
359 'childContextTypes',
360 'statics',
361 'loadProps',
362 'defaultProps',
363 'constructor',
364 'getDefaultProps',
365 'state',
366 'getInitialState',
367 'getDerivedStateFromProps',
368 'getChildContext',
369 'componentWillAppear',
370 'componentDidAppear',
371 'componentWillEnter',
372 'componentDidEnter',
373 'componentWillMount',
374 'UNSAFE_componentWillMount',
375 'componentDidMount',
376 'componentDidCatch',
377 'componentWillReceiveProps',
378 'UNSAFE_componentWillReceiveProps',
379 'shouldComponentUpdate',
380 'componentWillUpdate',
381 'UNSAFE_componentWillUpdate',
382 'componentDidUpdate',
383 'componentWillLeave',
384 'componentDidLeave',
385 'componentWillUnmount',
386 ],
387 },
388 }],
389 'react/sort-prop-types': ['error', {ignoreCase: true}],
390 'react/style-prop-object': 'error',
391 'react/void-dom-elements-no-children': 'error',
392 'rest-spread-spacing': ['error', 'never'],
393 'require-await': 'error',
394 'require-yield': 'error',
395 'semi-spacing': ['error', {before: false, after: true}],
396 'semi-style': ['error', 'last'],
397 'sort-imports': ['error', {
398 ignoreCase: true,
399 ignoreMemberSort: false,
400 memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
401 }],
402 'sort-vars': ['error', {ignoreCase: true}],
403 'space-before-blocks': 'error',
404 'space-before-function-paren': 'error',
405 'space-infix-ops': ['error', {int32Hint: false}],
406 'space-in-parens': ['error', 'never'],
407 'space-unary-ops': ['error', {words: true, nonwords: false}],
408 'spaced-comment': ['error', 'always'],
409 strict: ['error', 'global'],
410 'switch-colon-spacing': ['error', {after: true, before: false}],
411 'symbol-description': 'error',
412 'template-curly-spacing': ['error', 'never'],
413 'template-tag-spacing': ['error', 'always'],
414 'unicode-bom': 'error',
415 'use-isnan': 'error',
416 'valid-typeof': 'error',
417 'yield-star-spacing': ['error', {before: true, after: false}],
418 yoda: 'error',
419 'valid-jsdoc': ['error', {requireReturn: false}],
420 'wrap-iife': 'error',
421 'wrap-regex': 'error',
422
423 // WARNINGS
424
425 'array-callback-return': 'warn',
426 complexity: 'warn',
427 'flowtype/define-flow-type': 'warn',
428 'flowtype/require-parameter-type': 'warn',
429 'flowtype/require-return-type': ['warn', 'always', {
430 annotateUndefined: 'never',
431 }],
432 'flowtype/require-types-at-top': ['warn', 'always'],
433 'flowtype/require-valid-file-annotation': ['warn', 'always', {
434 annotationStyle: 'line',
435 }],
436 'flowtype/use-flow-type': 'warn',
437 'jasmine/no-disabled-tests': 'warn',
438 'jsx-a11y/click-events-have-key-events': 'warn',
439 'no-console': 'warn',
440 'no-warning-comments': ['warn', {terms: ['todo', 'fixme', 'future'], location: 'anywhere'}],
441 'react/boolean-prop-naming': ['warn', {rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+'}],
442 'react/jsx-handler-names': ['warn', {eventHandlerPrefix: '_handle', eventHandlerPropPrefix: 'on'}],
443 'react/no-find-dom-node': 'warn',
444 'react/no-unused-prop-types': ['warn', {skipShapeProps: true}],
445 'prefer-rest-params': 'warn',
446
447 // DISABLED
448
449 'array-bracket-newline': 'off',
450 'array-element-newline': 'off',
451 'arrow-body-style': ['off', 'as-needed'],
452 camelcase: 'off',
453 'capitalized-comments': 'off',
454 'class-methods-use-this': 'off',
455 curly: 'off',
456 'default-case': 'off',
457 'flowtype/no-mutable-array': 'off',
458 'func-names': 'off',
459 'function-paren-newline': 'off',
460 'id-blacklist': ['off', 'data', 'err', 'e', 'cb', 'callback'],
461 'id-length': ['off', {min: 3, max: 30, exceptions: ['i', 'x']}],
462 'id-match': ['off', '^[a-z]+([A-Z][a-z]+)*$', {properties: false}],
463 'implicit-arrow-linebreak': 'off',
464 // Doesn't let us leave Flow `export type` at the top of the file
465 'import/exports-last': 'off',
466 'import/max-dependencies': 'off',
467 'import/no-anonymous-default-export': 'off',
468 // Disabled because it can slow down linting, but may be worth trying out later:
469 'import/no-cycle': ['off', {maxDepth: 3}],
470 'import/no-dynamic-require': 'off',
471 'import/no-extraneous-dependencies': 'off',
472 'import/no-internal-modules': 'off',
473 'import/no-named-as-default': 'off',
474 'import/no-nodejs-modules': 'off',
475 'import/no-restricted-paths': 'off',
476 'import/no-unassigned-import': 'off',
477 'import/no-webpack-loader-syntax': 'off',
478 'import/order': 'off',
479 'import/unambiguous': 'off',
480 'init-declarations': 'off',
481 'jasmine/named-spy': 'off',
482 'jasmine/new-line-between-declarations': 'off',
483 'jasmine/new-line-before-expect': 'off',
484 'jasmine/no-assign-spyon': 'off',
485 'jasmine/no-describe-variables': 'off',
486 'jasmine/prefer-toHaveBeenCalledWith': 'off',
487 'jsx-a11y/label-has-for': 'off',
488 'jsx-a11y/no-autofocus': 'off',
489 'line-comment-position': 'off',
490 'linebreak-style': 'off',
491 'lines-around-comment': ['off', {beforeBlockComment: true, beforeLineComment: true}],
492 'multiline-comment-style': 'off',
493 'multiline-ternary': 'off',
494 'new-cap': 'off',
495 'no-case-declarations': 'off',
496 'no-confusing-arrow': 'off',
497 'no-continue': 'off',
498 'no-empty-function': 'off',
499 'no-eq-null': 'off',
500 'no-extra-parens': 'off',
501 'no-invalid-this': 'off',
502 'no-extra-label': 'off',
503 'no-magic-numbers': 'off',
504 'no-mixed-operators': 'off',
505 'no-mixed-requires': 'off',
506 'no-negated-condition': 'off',
507 'no-restricted-syntax': 'off',
508 'no-param-reassign': 'off',
509 'no-plusplus': 'off',
510 'no-restricted-globals': 'off',
511 'no-restricted-imports': 'off',
512 'no-restricted-properties': 'off',
513 'no-shadow': 'off',
514 'no-sync': 'off',
515 'no-ternary': 'off',
516 'no-tabs': 'off',
517 'no-undefined': 'off',
518 'no-underscore-dangle': 'off',
519 'no-unneeded-ternary': 'off',
520 'no-unused-labels': 'off',
521 'no-use-before-define': 'off',
522 'no-useless-return': 'off',
523 'nonblock-statement-body-position': 'off',
524 'object-curly-newline': 'off',
525 'object-curly-spacing': ['off', 'never'],
526 'object-property-newline': 'off',
527 'one-var': ['off', 'always'],
528 'padded-blocks': ['off', 'never'],
529 'prefer-destructuring': 'off',
530 'promise/avoid-new': 'off',
531 'promise/no-callback-in-promise': 'off',
532 'promise/no-nesting': 'off',
533 'react/button-has-type': 'off',
534 'react/destructuring-assignment': 'off',
535 'react/forbid-component-props': 'off',
536 'react/forbid-elements': 'off',
537 'react/jsx-filename-extension': 'off',
538 'react/jsx-first-prop-new-line': 'off',
539 'react/jsx-no-bind': 'off',
540 'react/jsx-no-literals': 'off',
541 'react/jsx-one-expression-per-line': 'off',
542 'react/no-array-index-key': 'off',
543 'react/no-set-state': 'off',
544 'react/no-string-refs': 'off',
545 'react/require-default-props': 'off',
546 'sort-keys': ['off', 'asc', {caseSensitive: false, natural: true}],
547 'vars-on-top': 'off',
548 },
549 settings: {
550 'import/ignore': ['node_modules', '.(css|json|less|md|styl)$'],
551 },
552
553 overrides: [
554 {
555 files: ['*.test.js'],
556 rules: {
557 'flowtype/require-parameter-type': 'off',
558 'flowtype/require-return-type': 'off',
559 'flowtype/require-valid-file-annotation': 'off',
560 },
561 },
562 ],
563};