-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
255 lines (223 loc) · 6.45 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
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
module.exports = {
globals: {
// Allow for self to be a mirror of window
self: true,
},
parser: "@typescript-eslint/parser",
extends: [
"airbnb-base",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
"plugin:eslint-comments/recommended",
"prettier",
],
env: {
browser: true,
node: true,
es6: true,
mocha: true,
},
plugins: [
"import",
"@typescript-eslint",
"simple-import-sort",
"unicorn",
"mocha",
],
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
rules: {
// //////// //
// Disabled //
// //////// //
/** Handled by prettier */
"comma-dangle": 0,
"operator-linebreak": 0,
"implicit-arrow-linebreak": 0,
"@typescript-eslint/indent": 0,
"object-curly-newline": 0,
"template-curly-spacing": 0,
"newline-per-chained-call": 0,
"generator-star-spacing": 0,
"computed-property-spacing": 0,
"space-before-function-paren": 0,
indent: 0,
"function-paren-newline": 0,
"no-confusing-arrow": 0,
"no-multi-spaces": 0,
"object-property-newline": 0,
"brace-style": 0,
"no-nested-ternary": 0,
/** handled by no-restricted-syntax */
"guard-for-in": 0,
/**
* Use types instead of interfaces
*/
"@typescript-eslint/prefer-interface": 0,
"@typescript-eslint/interface-name-prefix": 0,
// when we do use interfaces, they are often empty
"@typescript-eslint/no-empty-interface": 0,
/** Use import lint rules */
"@typescript-eslint/no-var-requires": 0,
/** No types required in some places, because of typescript */
"react/prop-types": 0,
"react/jsx-sort-props": 0,
"react/require-default-props": 0,
/** Because of @typescript-eslint, we don't need these */
"no-use-before-define": 0,
"no-shadow": 0,
camelcase: 0,
"no-var-requires": 0,
"no-inferrable-types": 0,
"unicorn/explicit-length-check": "error",
"no-underscore-dangle": "off",
"no-useless-constructor": 0,
/** Bad import rules, ignore them */
"import/no-named-as-default": 0,
"import/extensions": 0,
"import/prefer-default-export": 0,
// ///// //
// Rules //
// ///// //
/** Use === instead of == */
eqeqeq: ["error"],
/**
* Require class methods to call this
*/
"class-methods-use-this": ["error"],
/**
* @typescript-eslint rules
*/
"@typescript-eslint/unified-signatures": ["error"],
"@typescript-eslint/adjacent-overload-signatures": ["error"],
"@typescript-eslint/explicit-function-return-type": [
"error",
{ allowExpressions: true },
],
"@typescript-eslint/explicit-module-boundary-types": 0,
/** Import validation */
"import/imports-first": ["error"],
"import/newline-after-import": ["error"],
"import/no-dynamic-require": ["error"],
"import/no-unresolved": ["error"],
"import/no-webpack-loader-syntax": ["error"],
/**
* No console logs anywhere.
*/
"no-console": ["error"],
/** Use template strings for concatenation */
"prefer-template": ["error"],
/**
* Limits on file size and line length, for readability
*/
"max-len": ["error", 150, { comments: 150 }],
/** Require curly brackets around newlines */
curly: ["error"],
/** Ensure eslint-disable is not present when its not disabling any rule */
"eslint-comments/no-unused-disable": ["error"],
/** Arrow functions should have parentheses around inputs */
"arrow-parens": ["error", "always"],
"arrow-body-style": ["error", "as-needed"],
/** Max lines in a file */
"max-lines": ["error", 350],
/** Generator functions should call `yield` */
"require-yield": ["error"],
/** Prefer for-of to for loop */
"@typescript-eslint/prefer-for-of": ["error"],
/** Should not alias this to another command */
"@typescript-eslint/no-this-alias": ["error"],
/** Prevent use of global variables */
"no-restricted-globals": ["error"],
/** No unnecessary async statements on a function */
"require-await": ["error"],
/**
* If there are more than 4 arguments in a function, it should be refactored
* to have fewer arguments. The easiest way of doing this is to create an
* "options" parameter that holds all of the missing parameters
*
* @see https://eslint.org/docs/rules/max-params
*/
"max-params": ["error", 4],
/**
* Sort imports
*
* @see https://github.com/lydell/eslint-plugin-simple-import-sort
*/
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
// No unused imports or variables. Convenient for pre-commit hook.
"@typescript-eslint/no-unused-vars": 2,
// //////// //
// Warnings //
// //////// //
/** We want to eventually turn this to an error */
"@typescript-eslint/ban-types": ["warn"],
/** eslint-config-preact overrides */
"constructor-super": "off",
"no-redeclare": "off",
"no-duplicate-imports": "off",
"no-undef": "off",
"no-dupe-class-members": "off",
"no-unused-vars": "off", // we already have this covered by typescript-eslint config
"no-empty": ["error"],
"no-empty-pattern": ["error"],
"react/display-name": "off",
"mocha/no-skipped-tests": "error",
"mocha/no-exclusive-tests": "error",
},
overrides: [
/**
* Javascript files can ignore type requirements
*/
{
files: ["*.js", "*.mjs"],
rules: {
"@typescript-eslint/explicit-function-return-type": 0,
},
},
/**
* In test files, we allow them to be a bit longer
*/
{
files: ["**/*.spec.ts"],
rules: {
"no-unused-expressions": 0,
// Give a bit more leeway in test files
"max-lines": ["warn", 450],
},
},
{
files: ["*.ts"],
rules: {
"simple-import-sort/imports": [
"error",
{
groups: [
// Side effect imports.
["^\\u0000"],
// Anything not matched in another group.
["^"],
// Relative imports.
["^\\."],
],
},
],
},
},
],
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
/** Allow typescript alias resolution */
"import/resolver": {
typescript: {},
project: "tsconfig.json",
},
},
};