-
Notifications
You must be signed in to change notification settings - Fork 58
/
.eslintrc.js
197 lines (195 loc) · 6.93 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 = {
root: true,
env: {
browser: true,
es6: true,
node: true,
mocha: true,
},
globals: {
BigInt: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 10,
project: "./tsconfig.json",
sourceType: "module",
},
plugins: ["@typescript-eslint", "eslint-plugin-import", "prettier"],
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
],
rules: {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
//doesnt work, it reports false errors
"constructor-super": "off",
"import/order": [
"error",
{
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
pathGroupsExcludedImportTypes: ["builtin"],
},
],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{
allowExpressions: true,
},
],
"@typescript-eslint/func-call-spacing": "error",
// TODO after upgrading es-lint, member-ordering is now leading to lint errors. Set to warning now and fix in another PR
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/semi": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {accessibility: "no-public"}],
"@typescript-eslint/strict-boolean-expressions": [
"error",
{
allowNullableBoolean: true,
allowNullableString: true,
allowAny: true,
},
],
"@typescript-eslint/no-explicit-any": "off",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: false,
optionalDependencies: false,
peerDependencies: false,
},
],
"func-call-spacing": "off",
//if --fix is run it messes imports like /lib/presets/minimal & /lib/presets/mainnet
"import/no-duplicates": "off",
"import/no-relative-packages": "error",
"new-parens": "error",
"no-loss-of-precision": "error",
"no-caller": "error",
"no-bitwise": "off",
"no-cond-assign": "error",
"no-consecutive-blank-lines": 0,
"no-console": "error",
"no-var": "error",
"object-curly-spacing": ["off"],
"object-literal-sort-keys": 0,
"no-prototype-builtins": 0,
"prefer-const": "error",
quotes: ["error", "double"],
semi: "off",
"no-restricted-imports": [
"error",
{
patterns: ["../lib/*"],
paths: [
{name: "child_process", message: "Please use node:child_process instead."},
{name: "crypto", message: "Please use node:crypto instead."},
{name: "fs", message: "Please use node:fs instead."},
{name: "http", message: "Please use node:http instead."},
{name: "net", message: "Please use node:net instead."},
{name: "os", message: "Please use node:os instead."},
{name: "path", message: "Please use node:path instead."},
{name: "stream", message: "Please use node:stream instead."},
{name: "util", message: "Please use node:util instead."},
{name: "url", message: "Please use node:url instead."},
],
},
],
// Force to add names to all functions to ease CPU profiling
"func-names": ["error", "always"],
// TEMP Disabled while eslint-plugin-import support ESM (Typescript does support it) https://github.com/import-js/eslint-plugin-import/issues/2170
"import/no-unresolved": "off"
},
settings: {
"import/core-modules": [
"node:child_process",
"node:crypto",
"node:fs",
"node:http",
"node:net",
"node:os",
"node:path",
"node:stream",
"node:util",
"node:url",
],
},
overrides: [
{
files: ["**/*.config.js", "**/*.config.mjs", "**/*.config.cjs", "**/*.config.ts"],
rules: {
// Allow importing packages from dev dependencies
"import/no-extraneous-dependencies": "off",
// Allow importing and mixing different configurations
"import/no-relative-packages": "off",
"@typescript-eslint/naming-convention": "off",
// Allow require in CJS modules
"@typescript-eslint/no-var-requires": "off",
// Allow require in CJS modules
"@typescript-eslint/no-require-imports": "off",
},
},
{
files: ["**/test/**/*.ts"],
rules: {
"import/no-extraneous-dependencies": "off",
// Turned off as it floods log with warnings. Underlying issue is not critical so switching off is acceptable
"import/no-named-as-default-member": "off",
"func-names": "off",
},
},
{
files: ["**/test/**/*.test.ts"],
plugins: ["mocha"],
extends: ["plugin:mocha/recommended"],
rules: {
// We observed that having multiple top level "describe" save valuable indentation
// https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/max-top-level-suites.md
"mocha/max-top-level-suites": "off",
// We need to disable because we disabled "mocha/no-setup-in-describe" rule
// TODO: Move all setup code to before/beforeEach and then disable async describe
// https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-async-describe.md
"mocha/no-async-describe": "off",
// Use of arrow functions are very common
"mocha/no-mocha-arrows": "off",
// It's common to call function inside describe block
// https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-setup-in-describe.md
"mocha/no-setup-in-describe": "off",
// We use to split before in small isolated tasks
// https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-sibling-hooks.md
"mocha/no-sibling-hooks": "off",
},
},
{
files: ["**/types/**/*.ts"],
rules: {
"@typescript-eslint/naming-convention": [
"off",
{selector: "interface", prefix: ["I"]},
{selector: "interface", format: ["PascalCase"], prefix: ["I"]},
],
},
},
],
};