-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path.eslintrc.js
85 lines (74 loc) · 3.09 KB
/
.eslintrc.js
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
const { createConfig } = require('eslint-config-galex/src/createConfig');
const { files: jestFiles } = require('eslint-config-galex/src/overrides/jest');
const {
files: reactFiles,
} = require('eslint-config-galex/src/overrides/react');
const {
files: tsFiles,
} = require('eslint-config-galex/src/overrides/typescript');
module.exports = createConfig({
rules: {
'import/order': 'off',
'sort-keys-fix/sort-keys-fix': 'off', // keys should be sorted based on significance
'import/no-default-export': 'off', // default exports are common in React
'no-negated-condition': 'off', // ternaries are sometimes more readable when `true` branch is most significant branch
// Prefer explicit, consistent return - e.g. `return undefined;`
'unicorn/no-useless-undefined': 'off',
'consistent-return': 'error',
// Properties available after typeguard may be tedious to destructure (e.g. in JSX)
'unicorn/consistent-destructuring': 'off',
// Not really more readable and makes Jest crash
'unicorn/prefer-prototype-methods': 'off',
// zustand has `whitelist` option
'inclusive-language/use-inclusive-words': [
'error',
{ allowedTerms: ['whitelist'] },
],
},
overrides: [
{
files: reactFiles,
rules: {
'react/jsx-no-constructed-context-values': 'off', // too strict
},
},
{
files: tsFiles,
rules: {
'@typescript-eslint/ban-ts-comment': 'off', // too strict
'@typescript-eslint/no-floating-promises': 'off', // big crash sometimes better than silent fail
'@typescript-eslint/lines-between-class-members': 'off', // allow grouping single-line members
// TypeScript requires types where they should not be required
// https://github.com/typescript-eslint/typescript-eslint/issues/2183
'@typescript-eslint/explicit-module-boundary-types': 'off',
// Unused vars should be removed but not prevent compilation
'@typescript-eslint/no-unused-vars': [
'warn',
{ ignoreRestSiblings: true },
],
// Allow writing void-returning arrow functions in shorthand to save space
'@typescript-eslint/no-confusing-void-expression': [
'error',
{ ignoreArrowShorthand: true },
],
// Prefer `interface` over `type`
'@typescript-eslint/consistent-type-definitions': [
'error',
'interface',
],
// Disallows calling function with value of type `any` (disabled due to false positives)
// Re-enabling because has helped fix a good number of true positives
'@typescript-eslint/no-unsafe-argument': 'warn',
},
},
{
files: jestFiles,
rules: {
'jest/no-focused-tests': 'warn', // warning instead of error
'jest/prefer-strict-equal': 'off', // `toEqual` is shorter and sufficient in most cases
'jest-formatting/padding-around-all': 'off', // allow writing concise two-line tests
'jest/require-top-level-describe': 'off', // filename should already be meaningful, extra nesting is unnecessary
},
},
],
});