forked from sequelize/sequelize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
229 lines (205 loc) · 6.61 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
// eslint does not properly load plugins loaded by presets
// this fixes that
require('@rushstack/eslint-patch/modern-module-resolution');
module.exports = {
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/newline-after-description': 'error',
'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',
// We need to enable this in the next Major, it resolves a code smell
'unicorn/custom-error-definition': 'off',
// Enable this one if you want to prevent creating throwaway objects (perf)
'unicorn/no-object-as-default-parameter': 'off',
// sequelize needs to support node >= 12.
// Object.hasOwn, Array#at, String#replaceAll are available in node >= 16.
// `node:` protocol is available in node >= 14.
'prefer-object-has-own': 'off',
'unicorn/prefer-at': 'off',
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prefer-node-protocol': 'off',
// Too opinionated.
'unicorn/prevent-abbreviations': 'off',
'unicorn/prefer-switch': 'off',
// This rule is incompatible with DataTypes
'babel/new-cap': 'off',
// Too slow for the scale of this codebase
'import/no-deprecated': 'off',
'import/named': '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',
'babel/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',
// This would reduce the amount of things to bundle by eg. webpack.
'lodash/import-scope': '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: ['test/**/*.js'],
rules: {
'babel/no-invalid-this': 'off',
'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: ['test/**/*'],
rules: {
'import/no-extraneous-dependencies': 'off',
// no need to check jsdoc in tests & docs
'jsdoc/check-types': 'off',
'jsdoc/valid-types': 'off',
'jsdoc/newline-after-description': '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,
},
parserOptions: {
project: ['./test/tsconfig.json'],
},
}, {
files: ['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: ['dev/**/*'],
parserOptions: {
project: ['./dev/tsconfig.json'],
},
}],
settings: {
jsdoc: {
tagNamePreference: {
augments: 'extends',
},
structuredTags: {
typeParam: {
type: false,
required: ['name'],
},
internal: {
type: false,
},
},
},
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
ignorePatterns: [
'lib/**/*',
'types/**/*',
'.typedoc-build',
],
env: {
node: true,
mocha: true,
es6: true,
es2020: true,
},
};