-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
224 lines (214 loc) · 9.37 KB
/
index.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
/*
gregjoeval ESLint config
ESLint Rule Documentation: https://eslint.org/docs/rules/
AirBnB Javascript Style Guide: https://github.com/airbnb/javascript
Tool for comparing configs: https://sqren.github.io/eslint-compare/
Typescript ESLint: https://github.com/typescript-eslint/typescript-eslint
off: don't care or overriding rule config from plugin
warn: dont do this; writing code this way is not accepted but shouldn't prevent you from writing code during development
error: dont do this; writing code this way is not accepted; if you must break the rule you should use @ts-expect-error and provide a reason
*/
module.exports = {
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"promise",
"import-helpers"
],
// extended configs should be ordered by least to greatest importance
"extends": [
"plugin:import/typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"airbnb-base"
],
// https://stackoverflow.com/a/58323590/7571132
"settings": {
"import/resolver": {
"node": {
"extensions": [
".ts",
".tsx",
".js",
".jsx"
]
}
}
},
"rules": {
// Rules that cause issues between eslint and @typescript-eslint (https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules)
"brace-style": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"default-param-last": "off",
"dot-notation": "off",
"func-call-spacing": "off",
"indent": "off", // https://github.com/typescript-eslint/typescript-eslint/issues/1824
"init-declarations": "off",
"keyword-spacing": "off",
"lines-between-class-members": "off",
"no-array-constructor": "off",
"no-dupe-class-members": "off",
"no-duplicate-imports": "off",
"no-empty-function": "off",
"no-extra-parens": "off",
"no-extra-semi": "off",
"no-invalid-this": "off",
"no-loop-func": "off",
"no-loss-of-precision": "off",
"no-magic-numbers": "off",
"no-redeclare": "off",
"no-shadow": "off",
"no-throw-literal": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off",
"no-use-before-define": "off", // https://github.com/typescript-eslint/typescript-eslint/issues/1856
"no-useless-constructor": "off",
"object-curly-spacing": "off",
"quotes": "off",
"require-await": "off",
"no-return-await": "off", // return-await
"semi": "off",
"space-before-function-paren": "off",
"space-infix-ops": "off",
// ESLint (https://eslint.org/docs/rules/)
"spaced-comment": "warn",
"linebreak-style": ["off", "unix"],
"eol-last": ["error", "always"],
"max-len": ["error", {
"code": 225,
"ignoreComments": false,
"ignoreRegExpLiterals": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreUrls": true
}],
"no-case-declarations": "off",
"no-console": "warn",
"no-debugger": "warn",
"no-multiple-empty-lines": ["warn", { "max": 1 }],
"no-param-reassign": "error",
"no-underscore-dangle": "error",
"no-undefined": "warn",
"multiline-ternary": ["error", "always-multiline"],
"prefer-destructuring": "off",
"object-shorthand": ["error", "consistent"],
"object-property-newline": ["error", { "allowAllPropertiesOnSameLine": false }],
"object-curly-newline": ["error", {
"ObjectExpression": {
"consistent": true,
"multiline": true,
"minProperties": 2
},
"ObjectPattern": {
"consistent": true,
"multiline": true
},
"ImportDeclaration": {
"consistent": true,
"multiline": true
},
"ExportDeclaration": {
"consistent": true,
"multiline": true
}
}],
"function-paren-newline": ["error", "multiline"],
"implicit-arrow-linebreak": ["error", "beside"],
"jsx-quotes": ["error", "prefer-single"],
// Import Plugin (https://github.com/benmosher/eslint-plugin-import)
"import/prefer-default-export": "off",
"import/no-named-default": "off",
"import/no-named-as-default": "off",
"import/exports-last": "off",
"import/group-exports": "off",
"import/order": "off", // turned off in favor of import-helpers/order-imports
"import/no-unused-modules": ["off", { "unusedExports": true }], // keep turned off since it takes a long time to run, turn on only when checking for this rule
"import/no-duplicates": "error",
"import/newline-after-import": "error",
"import/no-useless-path-segments": "error",
"import/no-cycle": ["off", { "maxDepth": 2 }], // turning this off for now but should consider turning it on
"import/first": "error",
"import/extensions": ["error", "ignorePackages", {
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}],
"import/no-extraneous-dependencies": ["error", { "devDependencies": ["**/*.test.*", "**/*.d.*", "**/setupTests.ts", "**/*.stories.*"] }],
// Import Helpers Plugin (https://github.com/Tibfib/eslint-plugin-import-helpers)
"import-helpers/order-imports": ["warn", {
"newlinesBetween": "never",
"groups": ["absolute", "module", "parent", "sibling", "index"],
"alphabetize": { "order": "asc" }
}],
// Promise Plugin (https://github.com/xjamundx/eslint-plugin-promise)
"promise/catch-or-return": "error",
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/always-return": "error",
"promise/no-native": "off",
"promise/no-nesting": "error",
"promise/no-promise-in-callback": "error",
"promise/no-callback-in-promise": "error",
"promise/avoid-new": "error",
"promise/no-new-statics": "error",
"promise/no-return-in-finally": "error",
"promise/valid-params": "error",
"promise/prefer-await-to-then": "error",
"promise/prefer-await-to-callbacks": "off", // using callbacks for thunks since those cannot be awaited
// Typescript Plugin (https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin)
"@typescript-eslint/brace-style": "error",
"@typescript-eslint/comma-dangle": ["warn", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never", // parameters are positional and should not be easily re-arranged
"enums": "always-multiline",
"generics": "ignore", // in a .tsx file you need to do <T,> for generics so that it is not confused with jsx
"tuples": "always-multiline"
}],
"@typescript-eslint/indent": ["error", 4, { "SwitchCase": 1 }],
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/no-extra-parens": ["warn", "all", {
"nestedBinaryExpressions": false,
"ignoreJSX": "all",
"enforceForArrowConditionals": false,
"enforceForNewInMemberExpressions": false
}],
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/lines-between-class-members": ["warn", "always"],
"@typescript-eslint/quotes": ["error", "single", {
"avoidEscape": false,
"allowTemplateLiterals": false
}],
"@typescript-eslint/semi": ["warn", "never"],
"@typescript-eslint/explicit-function-return-type": ["error", {
"allowExpressions": true,
"allowTypedFunctionExpressions": true,
"allowHigherOrderFunctions": true
}],
"@typescript-eslint/naming-convention": ["error",
{
"selector": "interface",
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": true
}
}
],
"@typescript-eslint/interface-name-prefix": "off", // off in favor of @typescript-eslint/naming-convention
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/type-annotation-spacing": "warn",
"@typescript-eslint/object-curly-spacing": ["warn", "always"],
"@typescript-eslint/no-implicit-any-catch": "warn",
"@typescript-eslint/consistent-type-assertions": "warn", // https://basarat.gitbook.io/typescript/type-system/type-assertion#as-foo-vs-less-than-foo-greater-than
"@typescript-eslint/no-dynamic-delete": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/default-param-last": "error"
}
}