Repository navigation
Expand file tree
/
Copy patheslint.config.ts
More file actions
675 lines (668 loc) · 31.1 KB
/
Copy patheslint.config.ts
File metadata and controls
675 lines (668 loc) · 31.1 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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
import { PlatformCallDefaults, plugin, v8Plugin } from "@studnicky/eslint-config/node";
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 sonarjs from "eslint-plugin-sonarjs";
import unusedImports from "eslint-plugin-unused-imports";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";
const REPO_ROOT = decodeURIComponent(new URL(".", import.meta.url).pathname);
const TSCONFIG_ESLINT = `${REPO_ROOT}tsconfig.eslint.json`;
// node:assert is the test harness: its AssertionError is how node:test reports a failed test.
const TEST_PLATFORM_CALLS = PlatformCallDefaults.build().filter((entry) => {
const isAssert = entry.owner === "assert" || entry.owner === "assert/strict";
return !isAssert;
});
// 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: "coordinator", 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: "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: "primitive", pattern: "filters" },
{ unit: "package", layer: "capability", pattern: "fsm" },
{ unit: "package", layer: "foundation", pattern: "entity" },
{ unit: "package", layer: "primitive", pattern: "json" },
{ unit: "package", layer: "capability", pattern: "logger" },
{ unit: "package", layer: "coordinator", pattern: "matching" },
{ unit: "package", layer: "capability", pattern: "pipeline" },
{ unit: "package", layer: "coordinator", pattern: "resilience" },
{ unit: "package", layer: "coordinator", pattern: "retry" },
{ unit: "package", layer: "coordinator", pattern: "scheduler" },
{ unit: "package", layer: "primitive", pattern: "signal" },
{ unit: "package", layer: "coordinator", pattern: "system" },
{ unit: "package", layer: "coordinator", pattern: "throttle" },
{ 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: "coordinator", 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: "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: "primitive", pattern: "@studnicky/filters" },
{ unit: "module", layer: "capability", pattern: "@studnicky/fsm" },
{ unit: "module", layer: "foundation", pattern: "@studnicky/entity" },
{ unit: "module", layer: "primitive", pattern: "@studnicky/json" },
{ unit: "module", layer: "capability", pattern: "@studnicky/logger" },
{ unit: "module", layer: "coordinator", pattern: "@studnicky/matching" },
{ unit: "module", layer: "capability", pattern: "@studnicky/pipeline" },
{ unit: "module", layer: "coordinator", pattern: "@studnicky/resilience" },
{ unit: "module", layer: "coordinator", pattern: "@studnicky/retry" },
{ unit: "module", layer: "coordinator", pattern: "@studnicky/scheduler" },
{ unit: "module", layer: "primitive", pattern: "@studnicky/signal" },
{ unit: "module", layer: "coordinator", pattern: "@studnicky/system" },
{ 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",
};
const FILTERS_MATCHING_LAYERS = {
allowedImports: {
foundation: ["foundation"],
primitive: ["foundation", "primitive"],
capability: ["foundation", "primitive", "capability"],
coordinator: ["foundation", "primitive", "capability", "coordinator"],
},
bindings: [
{ unit: "folder", layer: "coordinator", pattern: "matching" },
{ unit: "module", layer: "foundation", pattern: "@studnicky/errors" },
{ unit: "module", layer: "coordinator", pattern: "@studnicky/matching" },
{ unit: "module", layer: "foundation", pattern: "@studnicky/types" },
],
layers: ["foundation", "primitive", "capability", "coordinator"],
sourceRoot: "packages/filters/src",
};
export default [
{
// Architectural bands and the error contract govern package source and tests. Examples are
// consumers — like any downstream application they compose across the whole toolkit, and
// `packages/fsm/examples` imports `@studnicky/scheduler`, a package that depends on `fsm`.
files: ["packages/*/src/**/*.ts", "packages/*/tests/**/*.ts"],
plugins: { "@studnicky": plugin },
rules: {
// The other four `arch/*` rules stay OFF, measured rather than assumed. All four 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.
// no-threaded-vocabulary 250 violations across 109 files (sourceRoot: 'packages').
// The rule expects a resolution site that exchanges a closed-vocabulary token for a
// port implementation; substrate has no port/adapter architecture for a token to
// resolve INTO, so a mode/kind/type enum threaded through an ordinary parameterized
// utility function is ubiquitous and legitimate here, not an unresolved token.
//
// `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],
// Every error a published package emits is a named BaseError subclass.
"@studnicky/no-native-error": "error",
},
},
{
files: ["packages/filters/src/matching/**/*.ts"],
rules: {
"@studnicky/layer-import-boundary": ["error", FILTERS_MATCHING_LAYERS],
},
},
{ ignores: [".claude/**", ".enginseer/**"] },
...defineConfig(
{
ignores: ["docs/.vitepress/cache/**", "**/dist/**", "**/node_modules/**", "**/*.d.ts"],
},
{
files: ["packages/*/src/**/*.ts", "packages/*/tests/**/*.ts", "packages/*/examples/**/*.ts"],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: REPO_ROOT,
},
},
linterOptions: {
reportUnusedDisableDirectives: "error",
},
plugins: {
"@studnicky": plugin,
"@studnicky/v8": v8Plugin,
"@stylistic": stylistic,
"import-x": importX,
perfectionist: perfectionistPlugin,
regexp: regexp,
sonarjs: sonarjs,
"unused-imports": unusedImports,
...(tseslint.plugin !== null && tseslint.plugin !== undefined
? { "@typescript-eslint": tseslint.plugin }
: {}),
},
rules: {
// @studnicky custom rules
"@studnicky/all-types-are-entities": "error",
"@studnicky/clean-diagnostics": "error",
"@studnicky/descriptive-identifiers": "error",
"@studnicky/direct-invocation-only": "error",
"@studnicky/explicit-return-binding": "error",
"@studnicky/entity-file-shape": "error",
"@studnicky/hash-private-fields": "error",
"@studnicky/inline-trivial-logic": "error",
"@studnicky/intake-parse-only": [
"error",
{
exemptPackages: [
"@studnicky/types",
"@studnicky/eslint-config",
"@studnicky/entity",
"@studnicky/drilldown",
],
},
],
"@typescript-eslint/no-unnecessary-type-parameters": "error",
"@studnicky/interface-must-be-contract": "error",
"@studnicky/export-shape": "error",
"@studnicky/interfaces-compose-named-types": "error",
"@studnicky/lexical-this-only": "error",
"@studnicky/no-caller-chosen-guard-type": "error",
"@studnicky/no-circular-imports": "error",
"@studnicky/no-double-assertion": "error",
"@studnicky/no-function-registries": "error",
"@studnicky/no-mixed-callable-shapes": "error",
"@studnicky/no-redefined-external-types": "error",
"@studnicky/no-reflect-argument-laundering": "error",
"@studnicky/no-unchecked-overload-implementation": "error",
"@studnicky/no-unparsed-assertion": "error",
"@studnicky/prefer-collection-types": "error",
"@studnicky/require-options-object": "error",
"@studnicky/static-method-verbs": "error",
"@studnicky/type-alias-invariants": "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",
{ checksVoidReturn: { inheritedMethods: false } },
],
"@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",
complexity: ["error", 10],
"max-depth": ["error", 4],
"max-lines": ["error", { max: 1000, skipBlankLines: true, skipComments: true }],
"max-lines-per-function": ["error", { max: 120, skipBlankLines: true, skipComments: true }],
"max-params": ["error", 5],
"no-nested-ternary": "error",
"sonarjs/cognitive-complexity": ["error", 15],
"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",
},
},
// Tooling — scripts, CI helpers and the docs site are procedural CLI/build code, not
// published package surfaces, so the package-authoring rules (entity shape, static-method
// dispatch, descriptive-identifier banlist) do not apply. Correctness, type-safety and
// style rules stay fully enforced.
{
files: ["scripts/**/*.ts", ".github/**/*.ts", "docs/**/*.ts"],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: REPO_ROOT,
},
},
linterOptions: {
reportUnusedDisableDirectives: "error",
},
plugins: {
"@stylistic": stylistic,
"import-x": importX,
perfectionist: perfectionistPlugin,
regexp: regexp,
sonarjs: sonarjs,
"unused-imports": unusedImports,
...(tseslint.plugin !== null && tseslint.plugin !== undefined
? { "@typescript-eslint": tseslint.plugin }
: {}),
},
rules: {
// @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",
{ checksVoidReturn: { inheritedMethods: false } },
],
"@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",
{
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-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",
complexity: ["error", 10],
"max-depth": ["error", 4],
"max-lines": ["error", { max: 1000, skipBlankLines: true, skipComments: true }],
"max-lines-per-function": ["error", { max: 120, skipBlankLines: true, skipComments: true }],
"max-params": ["error", 5],
"no-nested-ternary": "error",
"sonarjs/cognitive-complexity": ["error", 15],
"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/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 — type-aware against tsconfig.eslint.json, which includes every package's tests.
{
files: ["packages/*/tests/**/*.ts"],
languageOptions: {
parserOptions: {
project: [TSCONFIG_ESLINT],
projectService: false,
tsconfigRootDir: REPO_ROOT,
},
},
rules: {
"@studnicky/no-native-error": ["error", { platformCalls: TEST_PLATFORM_CALLS }],
},
},
// Config and framework entrypoints their loader requires to default-export.
{
files: [
"eslint.config.*",
"*.config.*",
"docs/.vitepress/config.ts",
"docs/.vitepress/theme/index.ts",
],
rules: {
"@studnicky/export-shape": "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],
projectService: false,
tsconfigRootDir: REPO_ROOT,
},
},
rules: {
"@studnicky/export-shape": "off",
"import-x/no-default-export": "off",
"no-console": "off",
},
},
// CLI tools write to stdout/stderr as their interface, not as debug residue.
{
files: ["scripts/**/*.ts", ".github/**/*.ts"],
rules: {
"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",
},
},
// The playground evaluator's entire purpose is running transpiled example source
// with an injected require shim — `new Function` is the mechanism, not a workaround.
{
files: ["docs/.vitepress/theme/utils/playgroundRuntime.ts"],
rules: {
"no-new-func": "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 }],
},
},
];