forked from dresende/node-orm2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eslintrc.js
More file actions
324 lines (282 loc) · 7.14 KB
/
.eslintrc.js
File metadata and controls
324 lines (282 loc) · 7.14 KB
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/**
* ESLint Configuration for node-orm3
*
* Enforces strict TypeScript practices including:
* - No explicit `any` types (drives adoption of proper typing)
* - Strong type checking
* - Consistent code style
* - Prevention of common errors
*/
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json',
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
plugins: ['@typescript-eslint'],
env: {
node: true,
es2020: true,
},
root: true,
rules: {
// ========== STRICT TYPE RULES ==========
/**
* Force explicit types instead of `any`
* This is the PRIMARY driver for the refactoring
*/
'@typescript-eslint/no-explicit-any': [
'error',
{
fixToUnknown: false,
ignoreRestArgs: false,
},
],
/**
* Warn about unused variables to keep code clean
*/
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
/**
* Require explicit function return types
*/
'@typescript-eslint/explicit-function-return-types': [
'warn',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
},
],
/**
* Prevent floating promises that aren't handled
*/
'@typescript-eslint/no-floating-promises': 'error',
/**
* Catch misused promises (e.g., passing promise to if statement)
*/
'@typescript-eslint/no-misused-promises': 'error',
/**
* Require proper error handling in promises
*/
'@typescript-eslint/promise-function-async': 'error',
/**
* Require proper async/await usage
*/
'@typescript-eslint/no-non-null-assertion': 'warn',
/**
* Enforce proper null checking
*/
'@typescript-eslint/strict-boolean-expressions': [
'warn',
{
allowString: false,
allowNumber: false,
allowNullableObject: false,
},
],
// ========== TYPE SAFETY RULES ==========
/**
* Prevent implicit any from index access
*/
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
/**
* Enforce consistent method overloads
*/
'@typescript-eslint/unified-signatures': 'error',
/**
* Require consistent return types
*/
'@typescript-eslint/consistent-return': 'warn',
/**
* Prevent unnecessary type assertions
*/
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
/**
* Prevent unnecessary conditionals
*/
'@typescript-eslint/no-unnecessary-condition': 'warn',
/**
* Enforce explicit accessibility modifiers
*/
'@typescript-eslint/explicit-member-accessibility': [
'warn',
{
accessibility: 'explicit',
overrides: {
constructors: 'no-public',
},
},
],
/**
* Enforce consistent naming conventions
*/
'@typescript-eslint/naming-convention': [
'warn',
{
selector: 'default',
format: ['camelCase'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
],
// ========== CODE QUALITY RULES ==========
/**
* Prevent console statements in production code
*/
'no-console': [
'warn',
{
allow: ['warn', 'error'],
},
],
/**
* Prevent debugger statements
*/
'no-debugger': 'error',
/**
* Prevent duplicate imports
*/
'no-duplicate-imports': 'error',
/**
* Enforce consistent spacing
*/
'indent': 'off', // Let prettier handle this
'@typescript-eslint/indent': 'off', // Let prettier handle this
/**
* Enforce semicolons
*/
'@typescript-eslint/semi': ['error', 'always'],
/**
* Enforce single quotes (except for strings with apostrophes)
*/
'@typescript-eslint/quotes': [
'error',
'single',
{
avoidEscape: true,
allowTemplateLiterals: true,
},
],
/**
* Enforce consistent comma spacing
*/
'@typescript-eslint/comma-spacing': 'error',
/**
* Enforce consistent object curly spacing
*/
'@typescript-eslint/object-curly-spacing': ['error', 'always'],
/**
* Enforce consistent keyword spacing
*/
'@typescript-eslint/keyword-spacing': 'error',
/**
* Prevent multiple statements on one line
*/
'no-multiple-empty-lines': ['error', { max: 1 }],
/**
* Prevent trailing whitespace
*/
'no-trailing-spaces': 'error',
/**
* Enforce consistent brace style
*/
'brace-style': ['error', '1tbs'],
/**
* Enforce consistent arrow function style
*/
'arrow-spacing': 'error',
// ========== PROMISE & ASYNC RULES ==========
/**
* Prevent loss of error information
*/
'@typescript-eslint/no-throw-literal': 'error',
/**
* Require return type annotations for functions in libraries
*/
'@typescript-eslint/no-implied-eval': 'error',
/**
* Prevent void operators in incorrect contexts
*/
'@typescript-eslint/no-void-type': 'off', // Allow for now, will reconsider
// ========== DISABLED RULES (We'll phase these in) ==========
/**
* These are disabled for now but should be enabled as we refactor:
* - They will become critical after Phase 2
*/
'@typescript-eslint/no-untyped-public-signature': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'warn',
// ========== EXISTING ESLINT COMPATIBILITY ==========
/**
* Turn off rules that conflict with our setup
*/
'no-redeclare': 'off', // TypeScript handles this
'no-undef': 'off', // TypeScript handles this
},
overrides: [
{
files: ['test/**/*.js', '**/*.test.ts', '**/*.spec.ts'],
env: {
jest: true,
},
rules: {
/**
* Allow any in tests (more lenient)
*/
'@typescript-eslint/no-explicit-any': 'warn',
/**
* Allow console in tests
*/
'no-console': 'off',
/**
* Allow unused variables in tests
*/
'@typescript-eslint/no-unused-vars': 'off',
},
},
{
files: ['examples/**/*.js'],
rules: {
/**
* Less strict for examples
*/
'@typescript-eslint/no-explicit-any': 'warn',
},
},
],
// Ignore patterns
ignorePatterns: [
'dist',
'node_modules',
'coverage',
'**/*.d.ts',
'examples',
],
};