-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
214 lines (194 loc) · 6 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
// eslint does not properly load plugins loaded by presets
// this fixes that
require('@rushstack/eslint-patch/modern-module-resolution');
module.exports = {
root: true,
extends: [
'@ephys/eslint-config-typescript',
'@ephys/eslint-config-typescript/node',
'@ephys/eslint-config-typescript/commonjs',
],
plugins: ['mocha', 'jsdoc'],
rules: {
'jsdoc/check-param-names': 'error',
'jsdoc/check-tag-names': 'error',
'jsdoc/check-types': 'off',
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }],
'jsdoc/no-undefined-types': 'off',
'jsdoc/require-description-complete-sentence': 'off',
'jsdoc/require-example': 'off',
'jsdoc/require-hyphen-before-param-description': 'off',
'jsdoc/require-param': 'error',
'jsdoc/require-param-description': 'off',
'jsdoc/require-param-name': 'error',
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-description': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/valid-types': 'error',
'jsdoc/no-types': 'error',
// enable this as an error, or keep disabled (not warning)
'unicorn/no-unsafe-regex': 'off',
// Enable this one if you want to prevent creating throwaway objects (perf)
'unicorn/no-object-as-default-parameter': 'off',
// Too opinionated
'unicorn/prefer-set-has': 'off',
},
overrides: [{
files: ['**/*.{js,mjs,cjs}'],
rules: {
'jsdoc/no-types': 'off',
'jsdoc/require-param-type': 'error',
'jsdoc/check-types': 'error',
'jsdoc/require-returns-type': 'error',
},
}, {
files: ['**/*.js'],
rules: {
// These rules have been disabled in .js files to ease adoption.
// They'll be fixed during the TS migration.
// Remove these once most files have been migrated to TS.
// This will catch a lot of bugs with early-returns
'consistent-return': 'off',
// code smells that should be resolved
'no-restricted-syntax': 'off',
'no-await-in-loop': 'off',
'unicorn/no-new-array': 'off',
'no-restricted-globals': 'off',
'default-case': 'off',
'no-loop-func': 'off',
'no-shadow': 'off',
'no-unused-vars': 'off',
'default-param-last': 'off',
'unicorn/error-message': 'off',
'no-implicit-coercion': 'off',
'no-fallthrough': 'off',
'no-invalid-this': 'off',
'prefer-rest-params': 'off',
'no-loss-of-precision': 'off',
// fromEntries is available in node 12. Restricted to v7.
'unicorn/prefer-object-from-entries': 'off',
// optimisation
'unicorn/consistent-function-scoping': 'off',
// array.reduce is difficult to reason about and can almost always
// be replaced by a more explicit method
'unicorn/no-array-reduce': 'off',
'unicorn/no-array-for-each': 'off',
'unicorn/prefer-spread': 'off',
// makes code clearer
'consistent-this': 'off',
'unicorn/no-this-assignment': 'off',
'unicorn/prefer-default-parameters': 'off',
'max-statements-per-line': 'off',
// makes debug easier
'func-names': 'off',
// multi-assigns can be difficult to understand
// https://eslint.org/docs/rules/no-multi-assign
'no-multi-assign': 'off',
// GitHub's display length is 125 chars.
// This enforces that length.
'max-len': 'off',
'max-depth': 'off',
// Reduce diff noise.
'import/order': 'off',
// consistency
'unicorn/filename-case': 'off',
// Passing a function reference to an array callback can accidentally introduce bug
// due to array methods passing more than one parameter.
'unicorn/no-array-callback-reference': 'off',
},
}, {
// most tests are written in old JS style
// let's disable the most problematic rules for now.
// they're only disabled for .js files.
// .ts files will need to migrate.
files: ['packages/*/test/**/*.js'],
rules: {
'func-names': 'off',
'import/order': 'off',
'no-invalid-this': 'off',
'no-unused-expressions': 'off',
camelcase: 'off',
'no-console': 'off',
'no-prototype-builtins': 'off',
'no-multi-spaces': 'off',
},
}, {
// Disable slow rules that are not important in tests (perf)
files: ['packages/*/test/**/*'],
rules: {
'import/no-extraneous-dependencies': 'off',
// no need to check jsdoc in tests & docs
'jsdoc/check-types': 'off',
'jsdoc/valid-types': 'off',
'jsdoc/tag-lines': 'off',
'jsdoc/check-tag-names': 'off',
// Enable test-specific rules (perf)
'mocha/no-exclusive-tests': 'error',
'mocha/no-skipped-tests': 'warn',
// it's fine if we're not very efficient in tests.
'no-inner-declarations': 'off',
'unicorn/no-unsafe-regex': 'off',
// because of Chai
'@typescript-eslint/no-unused-expressions': 'off',
},
env: {
mocha: true,
},
}, {
files: ['packages/*/test/types/**/*'],
rules: {
// This code is never executed, it's typing only, so these rules make no sense:
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'no-console': 'off',
},
}, {
files: ['**/tsconfig.json'],
rules: {
'json/*': ['error', { allowComments: true }],
},
}, {
files: ['sscce.ts'],
rules: {
'no-console': 'off',
},
}],
settings: {
jsdoc: {
tagNamePreference: {
augments: 'extends',
},
structuredTags: {
typeParam: {
type: false,
required: ['name'],
},
category: {
type: false,
required: ['name'],
},
internal: {
type: false,
},
hidden: {
type: false,
},
},
},
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
ignorePatterns: [
'packages/*/lib/**/*',
'packages/*/types/**/*',
'.typedoc-build',
],
env: {
node: true,
mocha: true,
es6: true,
es2020: true,
},
};