-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
469 lines (464 loc) · 25.5 KB
/
Copy patheslint.config.mjs
File metadata and controls
469 lines (464 loc) · 25.5 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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
import { plugin, v8Plugin } from '@studnicky/eslint-config';
import stylistic from '@stylistic/eslint-plugin';
import importX from 'eslint-plugin-import-x';
import perfectionistPlugin from 'eslint-plugin-perfectionist';
import regexp from 'eslint-plugin-regexp';
import unusedImports from 'eslint-plugin-unused-imports';
import tseslint from 'typescript-eslint';
// Architectural bands, derived from the measured `@studnicky/*` dependency DAG rather than a
// borrowed hexagonal vocabulary: a package's band is the depth of its longest internal
// dependency chain. Each band may import its own band and any band below it, never above. That
// invariant already holds — the graph carries zero upward dependencies — so these rules codify
// what the code does rather than imposing a new constraint.
//
// `package` bindings resolve the band of the FILE being linted: in a flat monorepo the
// layer-bearing unit is the package, whose directory name sits after `sourceRoot` and before
// `src`. `module` bindings resolve the band of an IMPORT, so a cross-package specifier lands on
// the same band as the file it points at. `allowedImports` is stated explicitly rather than left
// to the positional default, which encodes hexagonal asymmetries that do not describe a strict
// linear-cumulative policy.
const SUBSTRATE_LAYERS = {
'allowedImports': {
'foundation': ['foundation'],
'primitive': ['foundation', 'primitive'],
'capability': ['foundation', 'primitive', 'capability'],
'coordinator': ['foundation', 'primitive', 'capability', 'coordinator']
},
'bindings': [
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'batch' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'boundary-kit' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'bounded-dispatcher' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'cache' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'circular-buffer' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'clock' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'concurrency' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'config' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'context' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'drilldown' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'entity-store' },
{ 'unit': 'package', 'layer': 'foundation', 'pattern': 'errors' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'eslint-config' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'event-bus' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'fetch' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'file-lock' },
{ 'unit': 'package', 'layer': 'primitive', 'pattern': 'filters' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'flag-evaluator' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'fsm' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'health-registry' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'idempotency-guard' },
{ 'unit': 'package', 'layer': 'foundation', 'pattern': 'intake-kit' },
{ 'unit': 'package', 'layer': 'primitive', 'pattern': 'json' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'keyed-rate-limiter' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'keyed-work-gate' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'logger' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'matching' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'matching-filters' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'memoize' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'mutex' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'paginator' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'pipeline' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'process-kit' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'request-executor' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'resilience' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'retry' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'sample-buffer' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'scheduler' },
{ 'unit': 'package', 'layer': 'primitive', 'pattern': 'semantic-matching' },
{ 'unit': 'package', 'layer': 'primitive', 'pattern': 'signal' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'sliding-window-limiter' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'system' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'throttle' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'timing' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'topic-router' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'topic-router-models' },
{ 'unit': 'package', 'layer': 'foundation', 'pattern': 'types' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'virtual-fs' },
{ 'unit': 'package', 'layer': 'capability', 'pattern': 'visible-range' },
{ 'unit': 'package', 'layer': 'coordinator', 'pattern': 'worker-pool' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/batch' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/boundary-kit' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/bounded-dispatcher' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/cache' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/circular-buffer' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/clock' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/concurrency' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/config' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/context' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/drilldown' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/entity-store' },
{ 'unit': 'module', 'layer': 'foundation', 'pattern': '@studnicky/errors' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/eslint-config' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/event-bus' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/fetch' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/file-lock' },
{ 'unit': 'module', 'layer': 'primitive', 'pattern': '@studnicky/filters' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/flag-evaluator' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/fsm' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/health-registry' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/idempotency-guard' },
{ 'unit': 'module', 'layer': 'foundation', 'pattern': '@studnicky/intake-kit' },
{ 'unit': 'module', 'layer': 'primitive', 'pattern': '@studnicky/json' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/keyed-rate-limiter' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/keyed-work-gate' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/logger' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/matching' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/matching-filters' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/memoize' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/mutex' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/paginator' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/pipeline' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/process-kit' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/request-executor' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/resilience' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/retry' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/sample-buffer' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/scheduler' },
{ 'unit': 'module', 'layer': 'primitive', 'pattern': '@studnicky/semantic-matching' },
{ 'unit': 'module', 'layer': 'primitive', 'pattern': '@studnicky/signal' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/sliding-window-limiter' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/system' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/throttle' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/timing' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/topic-router' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/topic-router-models' },
{ 'unit': 'module', 'layer': 'foundation', 'pattern': '@studnicky/types' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/virtual-fs' },
{ 'unit': 'module', 'layer': 'capability', 'pattern': '@studnicky/visible-range' },
{ 'unit': 'module', 'layer': 'coordinator', 'pattern': '@studnicky/worker-pool' }
],
'layers': ['foundation', 'primitive', 'capability', 'coordinator'],
'sourceRoot': 'packages'
};
export default [
{
// Architectural bands govern what a PUBLISHED package depends on, so this applies to `src`
// only. Examples and tests are consumers — like any downstream application they compose
// across the whole toolkit, and `packages/fsm/examples` legitimately imports
// `@studnicky/scheduler`, a package that depends on `fsm` in turn. Constraining them would
// report a boundary that does not exist in anything shipped.
'files': ['packages/*/src/**/*.ts'],
'plugins': { '@studnicky': plugin },
'rules': {
// The other three `arch/*` rules stay OFF, measured rather than assumed. All three encode
// "a business-logic core with a conversion boundary around it"; substrate has neither —
// four bands of utility and infrastructure code, no domain layer, and no intake boundary
// separate from where a dependency is already wrapped.
//
// known-types-outside-adapters 587 violations at best band choice, 1144 at worst.
// `unknown` is this repo's own narrowing idiom, ~1177 uses across every band, the
// deliberate alternative to `any`. The heaviest packages (`json`, `errors`) sit in
// bands no choice of adapter layer exempts. Defensive typing INSIDE every layer is
// the toolkit's value, not a failure to convert at one edge.
// adapter-only-import 0 or 3, depending which band plays "adapters".
// The 3 are `fetch` importing `undici` — but `fetch` IS the adapter wrapping `undici`
// for the toolkit; there is no further layer to hide it behind. One adapter-shaped
// dependency exists across all 43 packages, so the rule has almost no surface here.
// domain-purity 1 violation: `BaseError`'s `Date.now()` timestamp,
// which is legitimate. No band is a domain layer; `foundation` is the closest only
// by being lowest, and it holds error handling and types, not business rules.
//
// `layer-import-boundary` is enabled because substrate genuinely HAS what it describes —
// a dependency-depth hierarchy with an enforceable upward-import ban — which is why it
// reports zero against real code instead of hundreds against real idioms.
'@studnicky/adapter-only-import': ['error', { ...SUBSTRATE_LAYERS, 'adapterLayerName': 'capability' }],
'@studnicky/domain-purity': ['error', { ...SUBSTRATE_LAYERS, 'domainLayerName': 'foundation' }],
'@studnicky/layer-import-boundary': ['error', SUBSTRATE_LAYERS]
}
},
{ ignores: ['.claude/**'] },
...tseslint.config(
{
'ignores': [
'docs/.vitepress/cache/**',
'**/dist/**',
'**/node_modules/**',
'**/*.d.ts'
]
},
{
'files': ['packages/*/src/**/*.ts', 'packages/*/examples/**/*.ts'],
'languageOptions': {
'parser': tseslint.parser,
'parserOptions': {
'projectService': true,
'tsconfigRootDir': import.meta.dirname
}
},
'linterOptions': {
'reportUnusedDisableDirectives': 'error'
},
'plugins': {
'@studnicky': plugin,
'@studnicky/v8': v8Plugin,
'@stylistic': stylistic,
'import-x': importX,
'perfectionist': perfectionistPlugin,
'regexp': regexp,
'unused-imports': unusedImports,
...tseslint.plugin !== null && tseslint.plugin !== undefined ? { '@typescript-eslint': tseslint.plugin } : {}
},
'rules': {
// @studnicky custom rules
'@studnicky/all-types-are-entities': 'error',
'@studnicky/canonical-export-names': 'error',
'@studnicky/clean-diagnostics': 'error',
'@studnicky/descriptive-identifiers': 'error',
'@studnicky/direct-invocation-only': 'error',
'@studnicky/explicit-return-binding': 'error',
'@studnicky/folder-content-shape': 'error',
'@studnicky/hash-private-fields': 'error',
'@studnicky/inline-trivial-logic': 'error',
'@studnicky/intake-parse-only': ['error', {
'exemptPackages': ['@studnicky/types', '@studnicky/eslint-config', '@studnicky/intake-kit', '@studnicky/drilldown']
}],
'@typescript-eslint/no-unnecessary-type-parameters': 'error',
'@studnicky/interface-must-be-contract': 'error',
'@studnicky/interface-suffix': 'error',
'@studnicky/interfaces-compose-named-types': 'error',
'@studnicky/lexical-this-only': 'error',
'@studnicky/no-mixed-callable-shapes': 'error',
'@studnicky/no-unparsed-assertion': 'error',
'@studnicky/prefer-collection-types': 'error',
'@studnicky/require-options-object': 'error',
'@studnicky/single-export': 'error',
'@studnicky/static-method-verbs': 'error',
'@studnicky/type-alias-invariants': 'error',
'@studnicky/whole-canonical-types': 'error',
// @studnicky/v8 optimisation rules
'@studnicky/v8/arguments-object': 'error',
'@studnicky/v8/array-concat-outside-loops': 'error',
'@studnicky/v8/array-from-iterators': 'error',
'@studnicky/v8/array-from-map-callback': 'error',
'@studnicky/v8/array-scan-outside-loops': 'error',
'@studnicky/v8/array-splice-outside-loops': 'error',
'@studnicky/v8/array-spread-outside-loops': 'error',
'@studnicky/v8/chained-array-iteration': 'error',
'@studnicky/v8/computed-class-properties': 'error',
'@studnicky/v8/computed-object-properties': 'error',
'@studnicky/v8/conditional-property-assignment': 'error',
'@studnicky/v8/define-property': 'error',
'@studnicky/v8/delete-property': 'error',
'@studnicky/v8/dynamic-property-access': 'error',
'@studnicky/v8/eval-function': 'error',
'@studnicky/v8/for-in-loops': 'error',
'@studnicky/v8/for-of-arrays': 'error',
'@studnicky/v8/inline-arrow-functions': 'error',
'@studnicky/v8/inline-functions': 'error',
'@studnicky/v8/max-switch-cases': 'error',
'@studnicky/v8/memoize-array-length': 'error',
'@studnicky/v8/object-spread': 'error',
'@studnicky/v8/prototype-modification': 'error',
'@studnicky/v8/regexp-in-loops': 'error',
'@studnicky/v8/switch-statements': 'error',
'@studnicky/v8/try-catch-in-loops': 'error',
'@studnicky/v8/with-statement': 'error',
// @stylistic
'@stylistic/comma-dangle': ['error', 'never'],
'@stylistic/eol-last': ['error', 'always'],
'@stylistic/indent': ['error', 2],
'@stylistic/no-trailing-spaces': 'error',
'@stylistic/quote-props': ['error', 'always'],
'@stylistic/quotes': ['error', 'single', { 'avoidEscape': true }],
'@stylistic/semi': ['error', 'always'],
// @typescript-eslint — auto-fixable set
'@typescript-eslint/array-type': ['error', { 'default': 'array' }],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': ['error', { 'fixStyle': 'separate-type-imports' }],
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
'custom': { 'match': true, 'regex': 'Interface$|^Type$' },
'format': ['PascalCase'],
'selector': 'interface'
},
{
'format': ['PascalCase'],
'selector': 'typeAlias'
}
],
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-explicit-any': ['error', { 'fixToUnknown': true }],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unused-vars': ['error', {
// `_`-prefixed args are intentionally-unused parameters on no-op
// template-method/lifecycle hooks that subclasses override.
'argsIgnorePattern': '^_',
'varsIgnorePattern': '^(_|[A-Z][A-Za-z]*Schema$|[A-Za-z]*Interface$|[A-Za-z]*Type$)'
}],
'@typescript-eslint/no-useless-empty-export': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-function-type': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/return-await': ['error', 'always'],
'@typescript-eslint/strict-boolean-expressions': ['error', {
'allowNullableObject': false,
'allowNumber': false,
'allowString': false
}],
// Core
'arrow-body-style': ['error', 'always'],
'consistent-return': 'error',
'curly': ['error', 'all'],
'eqeqeq': ['error', 'always'],
// import-x
'import-x/newline-after-import': 'error',
'import-x/no-default-export': 'error',
'no-array-constructor': 'error',
'no-case-declarations': 'error',
'no-class-assign': 'error',
'no-cond-assign': ['error', 'always'],
'no-console': 'error',
'no-const-assign': 'error',
'no-constant-condition': 'error',
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': ['error', { 'allowSeparateTypeImports': true }],
'no-else-return': ['error', { 'allowElseIf': false }],
'no-eq-null': 'error',
'no-eval': 'error',
'no-extra-bind': 'error',
'no-func-assign': 'error',
'no-global-assign': 'error',
'no-implicit-coercion': 'error',
'no-implicit-globals': 'error',
'no-invalid-regexp': 'error',
'no-lonely-if': 'error',
'no-multi-assign': 'error',
'no-nested-ternary': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-object-constructor': 'error',
'no-prototype-builtins': 'error',
'no-template-curly-in-string': 'error',
'no-throw-literal': 'error',
'no-unexpected-multiline': 'error',
'no-unreachable': 'error',
'no-unsafe-negation': 'error',
'no-unused-expressions': 'error',
'no-var': 'error',
'object-shorthand': ['error', 'never'],
'one-var': ['error', 'never'],
'perfectionist/sort-array-includes': ['error', { 'order': 'asc', 'type': 'natural' }],
'perfectionist/sort-classes': 'off',
'perfectionist/sort-decorators': ['error', { 'order': 'asc', 'type': 'natural' }],
// Perfectionist sorting
'perfectionist/sort-enums': 'error',
'perfectionist/sort-exports': 'error',
'perfectionist/sort-heritage-clauses': ['error', { 'order': 'asc', 'type': 'natural' }],
'perfectionist/sort-imports': 'error',
'perfectionist/sort-interfaces': 'error',
'perfectionist/sort-intersection-types': ['error', { 'order': 'asc', 'type': 'natural' }],
'perfectionist/sort-maps': ['error', { 'order': 'asc', 'type': 'natural' }],
'perfectionist/sort-modules': 'off',
'perfectionist/sort-named-exports': 'error',
'perfectionist/sort-named-imports': 'error',
'perfectionist/sort-object-types': 'error',
'perfectionist/sort-objects': 'error',
'perfectionist/sort-sets': ['error', { 'order': 'asc', 'type': 'natural' }],
'perfectionist/sort-switch-case': ['error', { 'order': 'asc', 'type': 'natural' }],
'perfectionist/sort-union-types': 'off',
'perfectionist/sort-variable-declarations': ['error', { 'order': 'asc', 'type': 'natural' }],
'prefer-const': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
// regexp
'regexp/no-unused-capturing-group': 'error',
'regexp/no-useless-flag': 'error',
'regexp/prefer-regexp-exec': 'error',
'require-yield': 'error',
// unused-imports
'unused-imports/no-unused-imports': 'error'
}
},
// Test files — parse with TS parser (no type-checking) and relax rules
{
'files': ['packages/*/tests/**/*.ts'],
'languageOptions': {
'parser': tseslint.parser,
'parserOptions': {
'project': false
}
},
'rules': {
'@studnicky/inline-trivial-logic': 'off',
'@studnicky/single-export': 'off',
'@studnicky/v8/for-of-arrays': 'off',
'@typescript-eslint/consistent-type-exports': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-magic-numbers': 'off',
'@typescript-eslint/no-meaningless-void-operator': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/return-await': 'off'
}
},
// Config-file overrides — allow default exports in config files
{
'files': ['eslint.config.*', '*.config.*', '*.config.mjs'],
'rules': {
'@studnicky/single-export': 'off',
'import-x/no-default-export': 'off'
}
},
// Example files — runnable demos. Full type-aware rigor via the dedicated
// tsconfig.eslint.json, relaxing only rules that govern library authoring
// (single-export modules) or that conflict with a demo's purpose (console
// output). Correctness, type-safety, and style rules stay fully enforced.
{
'files': ['packages/*/examples/**/*.ts'],
'languageOptions': {
'parserOptions': {
'project': ['./tsconfig.eslint.json'],
'projectService': false,
'tsconfigRootDir': import.meta.dirname
}
},
'rules': {
'@studnicky/single-export': 'off',
'import-x/no-default-export': 'off',
'no-console': 'off'
}
}
),
// Only these files are permitted to use `console` directly. ConsoleTransport
// is the logger's own console sink; all other logger-producing modules must
// route output through it. EventRecorder is deliberately raw, dependency-free
// console output — example/demo glue any package can use without pulling in
// @studnicky/logger as a dependency.
{
'files': [
'packages/logger/src/transports/ConsoleTransport.ts',
'packages/errors/src/observers/EventRecorder.ts'
],
'rules': {
'no-console': 'off'
}
},
// drilldown's matcher registry implements one shared interface (MatcherHandlerInterface) via
// plain object literals, not classes — the rule's own class-implementation exemption doesn't
// reach a handful of per-type methods (getSortKey, createNodeValue) that are genuinely pure
// field forwards by design (the interface contract IS "expose this field"). allowMemberExpressions
// is the rule's own documented escape valve for exactly this member-forward shape.
{
'files': ['packages/drilldown/src/**/*.ts'],
'rules': {
'@studnicky/inline-trivial-logic': ['error', { 'allowMemberExpressions': true }]
}
}
];