-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
188 lines (176 loc) · 4.97 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
module.exports = {
parserOptions: {
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/typescript",
"prettier",
],
plugins: ["tsdoc", "simple-import-sort", "import"],
env: {
node: true,
es6: true,
},
rules: {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/consistent-type-imports": "error",
"no-confusing-arrow": 0,
"no-else-return": 0,
"no-underscore-dangle": 0,
"no-restricted-syntax": 0,
"no-await-in-loop": 0,
"tsdoc/syntax": 2,
// Rules that we should enable:
"@typescript-eslint/no-inferrable-types": "warn",
"no-inner-declarations": "warn",
// Rules we've disabled for now because they're so noisy (but we should really address)
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
args: "after-used",
ignoreRestSiblings: true,
},
],
/*
* simple-import-sort seems to be the most stable import sorting currently,
* disable others
*/
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"sort-imports": "off",
"import/order": "off",
"import/extensions": ["error", "ignorePackages"],
"import/no-deprecated": "warn",
// Apply has been more optimised than spread, use whatever feels right.
"prefer-spread": "off",
// note you must disable the base rule as it can report incorrect errors
"no-duplicate-imports": "off",
"import/no-duplicates": "error",
},
overrides: [
// Rules for interfaces.ts files
{
files: ["**/interfaces.ts"],
rules: {
"no-restricted-syntax": [
"error",
{
selector: "TSModuleDeclaration[kind='global']",
message:
"No `declare global` allowed in `interface.ts` files since these type-only files may not be imported by dependents, recommend adding to `index.ts` instead.",
},
],
},
},
// Rules for TypeScript only
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
rules: {
"no-dupe-class-members": "off",
"no-undef": "off",
// This rule doesn't understand import of './js'
"import/no-unresolved": "off",
},
},
// Rules for JavaScript only
{
files: ["*.js", "*.jsx", "*.mjs", "*.cjs"],
rules: {
"tsdoc/syntax": "off",
"import/extensions": "off",
},
},
// Stricter rules for source code
{
files: ["*/*/src/**/*.ts", "*/*/src/**/*.tsx"],
extends: [
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
rules: {},
},
// Rules for tests only
{
files: ["**/__tests__/**/*.{ts,mts,js,mjs}"],
rules: {
// Disable these to enable faster test writing
"prefer-const": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-function-return-type": "off",
// We don't normally care about race conditions in tests
"require-atomic-updates": "off",
},
},
// Don't use Node.js builtins
{
files: ["src/**"],
rules: {
"@typescript-eslint/no-restricted-imports": [
"error",
{
paths: [
"assert",
"buffer",
"child_process",
"cluster",
"crypto",
"dgram",
"dns",
"domain",
"events",
"freelist",
"fs",
"fs/promises",
{ name: "http", allowTypeImports: true },
"https",
"module",
"net",
"os",
"path",
"punycode",
"querystring",
"readline",
"repl",
"smalloc",
"stream",
"string_decoder",
"sys",
"timers",
"tls",
"tracing",
"tty",
"url",
"util",
"vm",
"zlib",
],
patterns: ["node:*"],
},
],
},
},
],
};