-
Notifications
You must be signed in to change notification settings - Fork 9
/
.eslintrc.js
197 lines (197 loc) · 5.96 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
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
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:react/recommended', 'plugin:@typescript-eslint/recommended'],
settings: {
react: {
version: 'detect',
},
},
env: {
browser: true,
node: true,
es6: true,
},
plugins: ['@typescript-eslint', 'prettier', 'simple-import-sort'],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2019,
sourceType: 'module',
},
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// Npm packages. `react` related packages come first.
['^react', '^@?\\w'], // Internal packages
[
'^(actions|actionTypes|components|context|epics|hooks|middleware|reducers|routers|sources|stories|stylesheets|types|utils)(/.*|$)',
], // Side effect imports
['^\\u0000'], // Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'], // Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], // Style imports.
['^.+\\.s?css$'],
],
},
],
// avoid false positives for vars used only in types, and replace with ts version where possible
'no-unused-vars': ['off'],
'no-undef': ['off'],
// avoid false positives for optional chaining
'no-unused-expressions': 'off',
// don't require proptypes for typescript files because we have types
'react/prop-types': ['off'],
// rely on @typescript-eslint/require-await instead
'require-await': 'off',
// replaced by @typescript-eslint/no-shadow
'no-shadow': 'off',
// replaced by @typescript-eslint/naming-convention
camelcase: 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/member-ordering': 'off',
'@typescript-eslint/no-magic-numbers': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/typedef': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-var-requires': 'off',
// disable the need for explicit return types for all functions
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-inferrable-types': [
'error',
{
ignoreParameters: true,
},
],
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/no-parameter-properties': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/array-type': [
'error',
{
default: 'array-simple',
},
],
'@typescript-eslint/no-extraneous-class': [
'error',
{
allowEmpty: true,
},
],
'@typescript-eslint/no-explicit-any': 'error',
// TODO: The following rules can be enabled or improved but will require significant changes to do so
'no-use-before-define': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
'React.FunctionComponent': {
message: 'Add argument and return type instead.',
},
FunctionComponent: {
message: 'Add argument and return type instead.',
},
'React.PropsWithChildren': {
message: 'Be explicit in your (prop) type instead',
},
PropsWithChildren: {
message: 'Be explicit in your (prop) type instead',
},
// disable default object typing bans
Object: false,
'{}': false,
object: false,
},
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'variable',
format: ['camelCase', 'PascalCase'],
filter: {
regex: '.*(PropType)$',
match: true,
},
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'parameter',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
}, // the notifications reducer uses action types such as `teams/DELETE_TEAM_DONE` as object properties
{
selector: 'objectLiteralMethod',
format: null,
filter: {
regex: '^[a-z][a-zA-Z]*(/|.)[A-Z_]*$',
match: true,
},
},
{
selector: 'objectLiteralProperty',
format: null,
filter: {
regex: '^(__esModule|[a-z][a-zA-Z]*/[A-Z_]*)$',
match: true,
},
},
{
selector: 'memberLike',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'typeLike',
format: ['PascalCase', 'camelCase'],
},
{
selector: [
'classProperty',
'objectLiteralProperty',
'typeProperty',
'classMethod',
'objectLiteralMethod',
'typeMethod',
'accessor',
'enumMember',
],
format: null,
modifiers: ['requiresQuotes'],
},
],
},
};