@rexezuge/tooling 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/eslint.ts CHANGED
@@ -6,23 +6,14 @@
6
6
  * rules). Merged in from the other three stacks that share the same plugin set:
7
7
  *
8
8
  * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,
9
- * with a narrow override block for Vitest idioms), and
10
- * `unicorn/prefer-ternary` is off. Edge-Sonic's per-rule "deliberately does not
11
- * follow" block is carried over verbatim in spirit: each entry is off because
12
- * complying would make the code worse for what the project is, and each is
13
- * listed rather than dropped so the decision stays reviewable.
14
- * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.
9
+ * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`
10
+ * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary
11
+ * guard and its `apps/web` layer block.
15
12
  * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.
16
13
  * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses
17
- * `allowTypeImports` where the source repos do. It is also the source for the
18
- * anchored skip patterns and the symlink-safe walk that came out of its own backlog.
19
- * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,
20
- * with a narrow override block for Vitest idioms), `unicorn/prefer-ternary` is off
21
- * with a documented reason, and the `import()` hole in `no-restricted-imports` is
22
- * covered by a matching `no-restricted-syntax` rule. Edge-Sonic's per-rule
23
- * "deliberately does not follow" block is carried over verbatim in spirit: each
24
- * entry is off because complying would make the code worse for what the project
25
- * is, and each is listed rather than dropped so the decision stays reviewable.
14
+ * `allowTypeImports` where the source repos do not. It is also the source for
15
+ * the anchored skip patterns and the symlink-safe walk that came out of its own
16
+ * backlog.
26
17
  *
27
18
  * Canonical decisions, and why each one:
28
19
  *
@@ -32,6 +23,7 @@
32
23
  * 2. **The layered boundary rules are parameterized by `scope`.** Every source
33
24
  * repo wrote the same seven blocks with a different npm scope hardcoded; the
34
25
  * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.
26
+ * The table itself lives in {@link ./eslint-boundaries}.
35
27
  * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;
36
28
  * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated
37
29
  * violations that nothing reported.
@@ -47,8 +39,9 @@
47
39
  * zero-dependency, and the plugin belongs to the app that has JSX. A consumer
48
40
  * appends it — the README shows the four lines.
49
41
  *
50
- * The consumer's repo-level `eslint.config.mjs` becomes four lines, and a repo that
51
- * needs a boundary the canonical table does not name passes `extraLayers` — see
42
+ * The rule bodies live in {@link ./eslint-rules} and the boundary table in
43
+ * {@link ./eslint-boundaries}; this file is the assembly. A repo that needs a
44
+ * boundary the canonical table does not name passes `extraLayers` — see
52
45
  * {@link RepoLintConfigOptions}.
53
46
  */
54
47
 
@@ -60,6 +53,9 @@ import pluginRegexp from 'eslint-plugin-regexp';
60
53
  import eslintConfigPrettier from 'eslint-config-prettier';
61
54
  import prettier from 'eslint-plugin-prettier';
62
55
  import type { FlatConfig } from 'typescript-eslint';
56
+ import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries';
57
+ import type { LayerBan } from './eslint-boundaries';
58
+ import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules';
63
59
 
64
60
  /**
65
61
  * What `defineRepoLintConfig` accepts.
@@ -120,155 +116,17 @@ function asConfig(config: MaybeConfig): ConfigInput {
120
116
  }
121
117
 
122
118
  /**
123
- * The directories the boundary rules cover, in the canonical layout.
124
- */
125
- const DEFAULT_PROJECT_DIRS: readonly string[] = [
126
- 'packages/shared',
127
- 'packages/backend-errors',
128
- 'packages/backend-runtime',
129
- 'packages/backend-data',
130
- 'packages/backend-services',
131
- 'apps/api',
132
- 'apps/background',
133
- 'apps/web',
134
- ];
135
-
136
- /**
137
- * One layer's ban list, as the repo-relative package suffixes it may not import.
138
- *
139
- * Converged from the four source stacks. `backend-data` and `backend-services`
140
- * appear in all four; `webdav`/`dav-store` are Durable-DAV's, `provider-clients`
141
- * is Mail-Meow's and AWS's. A layer only bans what exists in its repo, so the
142
- * union is safe: a repo without `provider-clients` simply never imports it.
143
- */
144
- export interface LayerBan {
145
- /** Directory the rule is scoped to. */
146
- readonly dir: string;
147
- /** Package suffixes (relative to `scope`) that may not be imported from here. */
148
- readonly ban: readonly string[];
149
- /** Message shown when the rule fires. */
150
- readonly message: string;
151
- /** Type-only imports are allowed, for the DAO boundary in `apps/api`. */
152
- readonly allowTypeImports?: boolean;
153
- }
154
-
155
- /**
156
- * The layer table, parameterized by `scope`.
157
- *
158
- * Each entry reproduces the corresponding block in Durable-DAV's
159
- * `eslint.config.mjs` with `@durable-dav/` replaced by the caller's scope. The
160
- * table is data rather than seven inline blocks so the dynamic-`import()` guard
161
- * below can be generated from the same list — a rule that derived its banned set
162
- * from another rule's configuration would be a second source of truth for the
163
- * layer table, and that table is what the docs describe.
164
- */
165
- function layerBans(scope: string): readonly LayerBan[] {
166
- const at = (name: string): string => `${scope}/${name}`;
167
- return [
168
- {
169
- dir: 'packages/shared',
170
- ban: [at('*')],
171
- message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,
172
- },
173
- {
174
- dir: 'packages/backend-errors',
175
- ban: [at('*')],
176
- message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,
177
- },
178
- {
179
- dir: 'packages/backend-runtime',
180
- ban: [at('backend-data'), at('webdav'), at('backend-services'), at('api'), at('background')],
181
- message: 'backend-runtime must not import from a higher layer',
182
- },
183
- {
184
- dir: 'packages/backend-data',
185
- ban: [at('backend-runtime'), at('webdav'), at('backend-services'), at('api'), at('background')],
186
- message: 'backend-data must not import from a higher layer',
187
- },
188
- {
189
- dir: 'packages/backend-services',
190
- ban: [at('api'), at('background')],
191
- message: 'backend-services must not import from apps',
192
- },
193
- {
194
- dir: 'apps/api',
195
- ban: [at('backend-data/dao'), at('backend-data')],
196
- allowTypeImports: true,
197
- message: 'apps/api must not import DAOs or backend-data values directly; use backend-services instead',
198
- },
199
- {
200
- dir: 'apps/background',
201
- ban: [at('api')],
202
- message: 'apps/background must not import from apps/api',
203
- },
204
- // The browser half, and the only layer that bans the namespace wholesale
205
- // rather than a list of siblings: a backend package imported by the SPA
206
- // typechecks and then fails at bundle time, with the error pointing at the
207
- // bundler rather than at the boundary. Edge-Sonic is the source; the others had
208
- // no block for it at all, which is how their layer table's "may import: the
209
- // browser" was a convention instead of a gate.
210
- {
211
- dir: 'apps/web',
212
- ban: [at('*')],
213
- message: `${at('apps/web')} ships zero backend dependencies — this module is the SPA's own copy`,
214
- },
215
- ];
216
- }
217
-
218
- /**
219
- * The `no-restricted-imports` entries for one layer.
119
+ * Bridge a rule block onto `tseslint.config()`'s `rules` field.
220
120
  *
221
- * Written as `group` patterns rather than exact `paths`, so `@myapp/backend-data`
222
- * and `@myapp/backend-data/dao` are both caught by one entry. `allowTypeImports`
223
- * is passed through only where the source repos set it, because
224
- * `apps/api` legitimately types its filters and models against DAO shapes.
121
+ * The blocks in `eslint-rules.ts` are written as ESLint expects them —
122
+ * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a
123
+ * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`
124
+ * union is narrower than the data shape, and widening every entry to that union
125
+ * would buy nothing; one assertion here, with the reason, is the cheaper and
126
+ * more honest of the two.
225
127
  */
226
- function restrictedImports(bans: readonly LayerBan[]): FlatConfig.Config[] {
227
- return bans.map(({ dir, ban, message, allowTypeImports }) => ({
228
- files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],
229
- rules: {
230
- 'no-restricted-imports': [
231
- 'error',
232
- {
233
- patterns: ban.map((group) => ({
234
- group: [group, `${group}/*`],
235
- message,
236
- ...(allowTypeImports === true && { allowTypeImports: true }),
237
- })),
238
- },
239
- ],
240
- },
241
- }));
242
- }
243
-
244
- /**
245
- * The dynamic-`import()` guard, generated from the same table.
246
- *
247
- * `no-restricted-imports` reads `ImportDeclaration` nodes only; a dynamic
248
- * `import()` is an `ImportExpression`, and this ESLint version does not report it
249
- * under that rule at all. Edge-Sonic verified this rather than assumed it — a
250
- * static import of a restricted specifier from the same file is an `error`, and
251
- * the identical specifier reached through `await import(...)` is silent. That
252
- * hole was load-bearing there: the credential path reached a banned module
253
- * through it. `no-restricted-syntax` sees `ImportExpression`, so the boundary is
254
- * stated a second way.
255
- *
256
- * The specifier list is duplicated from the layer table on purpose; see the
257
- * comment on `layerBans`.
258
- */
259
- function restrictedDynamicImports(bans: readonly LayerBan[]): FlatConfig.Config[] {
260
- return bans.map(({ dir, ban, message }) => ({
261
- files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],
262
- rules: {
263
- 'no-restricted-syntax': [
264
- 'error',
265
- ...ban.map((specifier) => ({
266
- selector: `ImportExpression[source.type='Literal'][source.value=/^${specifier.replaceAll('/', '\\/')}/]`,
267
- message: `A dynamic import() is not covered by no-restricted-imports, so this layer reaches \`${specifier}\` through the one syntax that gate does not see. Both say no: ${message}`,
268
- })),
269
- ],
270
- },
271
- }));
128
+ function asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {
129
+ return block as FlatConfig.Config['rules'];
272
130
  }
273
131
 
274
132
  /**
@@ -336,198 +194,19 @@ export function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig
336
194
  // --- typescript-eslint overrides (identical in all four source stacks) ---
337
195
  {
338
196
  files: ['**/*.{ts,mts,cts,tsx}'],
339
- rules: {
340
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
341
- // Allow `void expr` for intentional fire-and-forget in Workers.
342
- '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
343
- // Relax the unsafe-any rules to warn: the external API boundaries
344
- // (Cloudflare bindings, provider SDKs) are typed `any` upstream, and the
345
- // alternative is a config that cannot be adopted.
346
- '@typescript-eslint/no-explicit-any': 'warn',
347
- '@typescript-eslint/no-unsafe-assignment': 'warn',
348
- '@typescript-eslint/no-unsafe-member-access': 'warn',
349
- '@typescript-eslint/no-unsafe-call': 'warn',
350
- '@typescript-eslint/no-unsafe-return': 'warn',
351
- '@typescript-eslint/no-unsafe-argument': 'warn',
352
- // JSX event handlers and hook callback objects commonly use async
353
- // functions where void is expected.
354
- '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { attributes: false, properties: false } }],
355
- },
197
+ rules: asRules(TYPESCRIPT_RULES),
356
198
  },
357
199
 
358
200
  // --- Unicorn: modern JS/TS quality rules ---
359
201
  asConfig(unicorn.configs['flat/recommended']),
360
202
  {
361
- rules: {
362
- // Codebase uses ctx, req, res, env, err, util, db, dao, etc. — too
363
- // invasive to rename.
364
- 'unicorn/prevent-abbreviations': 'off',
365
- // D1/DAO layer returns null; disabling this avoids mass rewrites.
366
- 'unicorn/no-null': 'off',
367
- // Monorepo uses CommonJS-compatible module style in some configs.
368
- 'unicorn/prefer-module': 'off',
369
- // Top-level await not available in all Workers entry points.
370
- 'unicorn/prefer-top-level-await': 'off',
371
- // Error subclassing via `new MyError()` is intentional in backend-errors.
372
- 'unicorn/custom-error-definition': 'off',
373
- // Allow process.exit in build/script files.
374
- 'unicorn/no-process-exit': 'off',
375
- // Array reduce is used intentionally in analytics/data transformation.
376
- 'unicorn/no-array-reduce': 'off',
377
- // Allow Number() — parseInt/parseFloat are used in some cases intentionally.
378
- 'unicorn/prefer-number-properties': ['error', { checkInfinity: false }],
379
- // Allow nested ternaries in JSX (React render patterns).
380
- 'unicorn/no-nested-ternary': 'off',
381
- // Allow Array.from — codebase uses it for iterables.
382
- 'unicorn/prefer-spread': 'off',
383
- // Entire codebase uses PascalCase for TS files; kebab-case would require
384
- // mass renames.
385
- 'unicorn/filename-case': 'off',
386
- // Established names should not be force-renamed.
387
- 'unicorn/name-replacements': 'off',
388
- // Zod schema builder chains and other deep method chains are intentional.
389
- 'unicorn/max-nested-calls': 'off',
390
- // import.meta.dirname is not available in all test environments.
391
- 'unicorn/prefer-import-meta-properties': 'off',
392
- // Codebase uses `err` as catch parameter name throughout.
393
- 'unicorn/catch-error-name': 'off',
394
- // Established boolean param names (retryable, enabled, etc.).
395
- 'unicorn/consistent-boolean-name': 'off',
396
- // Uint8Array#toBase64 / fromBase64 are not in all Workers runtime versions.
397
- 'unicorn/prefer-uint8array-base64': 'off',
398
- // Class member ordering would require extensive restructuring.
399
- 'unicorn/consistent-class-member-order': 'off',
400
- // API response fields use verb prefixes by convention.
401
- 'unicorn/no-non-function-verb-prefix': 'off',
402
- // forEach is used intentionally throughout the provider and utility layers.
403
- 'unicorn/no-for-each': 'off',
404
- // .then() chains in DAO and provider layers are often intentional.
405
- 'unicorn/prefer-await': 'warn',
406
- // Callback references (e.g. .map(Number)) are sometimes intentional.
407
- 'unicorn/no-array-callback-reference': 'warn',
408
- // toSorted() is ES2023 and may not be in all tsconfig lib targets.
409
- 'unicorn/no-array-sort': 'warn',
410
- // Early-return guard clauses are the established style; the rule only
411
- // rewrites the final guard of a ladder, which yields asymmetric mixed
412
- // style and long inline ternaries. Off in Mail-Meow and Edge-Sonic;
413
- // canonical here because it is the family's established style.
414
- 'unicorn/prefer-ternary': 'off',
415
- // `(await x).y` -> a named intermediate. Fires constantly in the tests,
416
- // where destructuring beside the assertion it serves is clearer.
417
- 'unicorn/no-await-expression-member': 'off',
418
- // `Number(x)` over `+x`: the `+` form is used where an explicit typeof
419
- // check has already narrowed the operand.
420
- 'unicorn/prefer-number-coercion': 'off',
421
- // Code-point iteration: the byte-level readers index deliberately,
422
- // because the offset *is* what they are reading.
423
- 'unicorn/prefer-code-point': 'off',
424
- // `if (!x) return;` over a compound condition: one guard per line, each
425
- // with its own comment, is what keeps endpoint guards readable.
426
- 'unicorn/prefer-simple-condition-first': 'off',
427
- // Module-scope `let` assigned from `beforeEach` in the test harnesses.
428
- 'unicorn/no-top-level-assignment-in-function': 'off',
429
- // Sequential `for...of` with `await` in the DAOs — D1's subrequest
430
- // budget is the scarce resource.
431
- 'unicorn/no-unreadable-for-of-expression': 'off',
432
- // `Object.hasOwn` over `in`: used where a prototype-chain hit is harmless.
433
- 'unicorn/no-computed-property-existence-check': 'off',
434
- // A labeled `break` out of two loops.
435
- 'unicorn/no-break-in-nested-loop': 'off',
436
- // `this` outside a class body: the module-level cache singletons
437
- // document their `this` contract in prose.
438
- 'unicorn/no-this-outside-of-class': 'off',
439
- // A class named inside its own static method.
440
- 'unicorn/class-reference-in-static-methods': 'off',
441
- // `void promise` where initiating the call is the point and the rejection
442
- // is handled at a named site elsewhere.
443
- 'sonarjs/void-use': 'off',
444
- // An `async` function with no `await`: every handler and DAO method is
445
- // `async` by shape so a future `await` does not change its signature.
446
- '@typescript-eslint/require-await': 'off',
447
- // Backtracking risk in bounded-prefix readers that run over a file the
448
- // server already chose to fetch, never over a request parameter.
449
- 'sonarjs/super-linear-regex': 'off',
450
- // Assigning `globalThis.fetch` in a test — the only way to intercept the
451
- // ambient fetch in Node without a module mock.
452
- 'unicorn/no-global-object-property-assignment': 'off',
453
- // `(a ? b : c) && d`: written longhand so each precedence decision is
454
- // visible.
455
- 'unicorn/prefer-logical-operator-over-ternary': 'off',
456
- // `children[0]` in the XML helpers, which index a child list positionally.
457
- 'unicorn/better-dom-traversing': 'off',
458
- // `entries()` -> `keys()`/`values()`: the full entry is destructured.
459
- 'unicorn/prefer-iterator-to-array': 'off',
460
- // `.map(fn, thisArg)`: rejected on purpose.
461
- 'unicorn/no-array-method-this-argument': 'off',
462
- // A module-scope function that closes over nothing.
463
- 'unicorn/consistent-function-scoping': 'off',
464
- // `foo[0] === 'a' || foo[0] === 'b'` written longhand where the
465
- // alternatives are not adjacent.
466
- 'unicorn/prefer-includes-over-repeated-comparisons': 'off',
467
- // A `type` alias over an inline union, where the name is what makes the
468
- // signature and its doc comment readable.
469
- 'sonarjs/use-type-alias': 'off',
470
- // A short local alias for a type imported from a protocol package.
471
- 'sonarjs/redundant-type-aliases': 'off',
472
- // `type: value` narrowing the other way, where both spellings appear in
473
- // the same schema and the code follows whichever the spec uses there.
474
- 'sonarjs/no-nested-assignment': 'off',
475
- // `Number.isInteger` plus a separate range check, where the bounds come
476
- // from the caller's own options in one place.
477
- 'unicorn/prefer-number-is-safe-integer': 'off',
478
- // `\u{...}` over a `\xNN` escape: the table is written in the byte form
479
- // the spec prints.
480
- 'unicorn/prefer-unicode-code-point-escapes': 'off',
481
- // `self.x = this.x` in an entry model: the alias makes the verbatim
482
- // round-trip explicit.
483
- 'unicorn/no-this-assignment': 'off',
484
- // Building a `Set` at module scope from a constant list, for O(1)
485
- // membership on a path that runs per parameter.
486
- 'unicorn/no-top-level-side-effects': 'off',
487
- // `await` on a value the types say is not thenable, where the value is a
488
- // `PromiseLike` from an interface declared that way.
489
- '@typescript-eslint/await-thenable': 'off',
490
- // A conditional whose branches are identical, kept where the two branches
491
- // are named separately to document that they are meant to diverge.
492
- 'sonarjs/no-all-duplicated-branches': 'off',
493
- // An `else` after a `return`: the flat form keeps the remaining cases at
494
- // one indent level in the dispatch tables.
495
- 'unicorn/prefer-else-if': 'off',
496
- // A nested ternary in a sort comparator, where the three-way order is the
497
- // point.
498
- 'unicorn/prefer-minimal-ternary': 'off',
499
- // `x === undefined` reported as always-true/false. With
500
- // `noUncheckedIndexedAccess` on, the guard is exactly right.
501
- 'sonarjs/different-types-comparison': 'off',
502
- // An accumulating loop with a sequential `await` in it, over D1 writes.
503
- 'unicorn/prefer-array-from-async': 'off',
504
- },
203
+ rules: asRules(UNICORN_RULES),
505
204
  },
506
205
 
507
206
  // --- SonarJS: code smell and bug detection ---
508
207
  asConfig(sonarjsConfigs.recommended),
509
208
  {
510
- rules: {
511
- // Raise duplicate-string threshold to avoid flagging intentional repeated
512
- // literals like provider IDs.
513
- 'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }],
514
- // Cognitive complexity — warn rather than error, so the ratchet can move
515
- // without a red build. Raise the number only as files are decomposed.
516
- 'sonarjs/cognitive-complexity': ['warn', 20],
517
- // False positives: connection method names like 'imap-password' and
518
- // field names like 'password_hash'.
519
- 'sonarjs/no-hardcoded-passwords': 'off',
520
- // Third-party deprecations are warnings, not errors.
521
- 'sonarjs/deprecation': 'warn',
522
- // Nested ternaries in complex data-mapping code.
523
- 'sonarjs/no-nested-conditional': 'warn',
524
- // React component props are commonly not marked Readonly<>.
525
- 'sonarjs/prefer-read-only-props': 'warn',
526
- // Static readonly properties require invasive refactoring.
527
- 'sonarjs/public-static-readonly': 'warn',
528
- // Nested template literals in SQL queries and prompt construction.
529
- 'sonarjs/no-nested-template-literals': 'warn',
530
- },
209
+ rules: asRules(SONARJS_RULES),
531
210
  },
532
211
 
533
212
  // --- Regexp: static analysis for regular expressions ---
@@ -568,73 +247,11 @@ export function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig
568
247
 
569
248
  // --- Test suite ---
570
249
  //
571
- // `test/**` is deliberately NOT in the ignores list above. Durable-DAV,
572
- // AWS and Mail-Meow all ignored it, and ~200 KB of test code had accumulated
573
- // violations that nothing reported. This block puts the suite back under the
574
- // same rules as the rest of the workspace and switches off only the handful
575
- // whose findings are structural artefacts of test code rather than defects.
576
- // It does not disable correctness rules: the unused-variable, dead-store,
577
- // regex and sorting findings in the suite are real and are fixed, not
578
- // suppressed.
250
+ // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES
251
+ // for the override block and the reasoning behind it.
579
252
  {
580
253
  files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],
581
- rules: {
582
- // `it('…', async () => …)` is the Vitest idiom.
583
- '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { arguments: false, attributes: false } }],
584
- // Unbound method is a common false positive in mock assertions like
585
- // expect(fn).toHaveBeenCalledWith(...).
586
- '@typescript-eslint/unbound-method': 'off',
587
- // Test helpers and stubs routinely use async functions without await.
588
- '@typescript-eslint/require-await': 'off',
589
- // Redundant type constituents appear in typed mock stubs.
590
- '@typescript-eslint/no-redundant-type-constituents': 'off',
591
- // `as never` casts are the standard fake-DB double pattern in tests.
592
- '@typescript-eslint/no-unnecessary-type-assertion': 'off',
593
- // Promise.withResolvers() and function-scoping refactors are cosmetic.
594
- 'unicorn/prefer-promise-with-resolvers': 'off',
595
- 'unicorn/consistent-function-scoping': 'off',
596
- // Fake-DB builders push-then-return and sort without comparators.
597
- 'unicorn/no-return-array-push': 'off',
598
- 'unicorn/require-array-sort-compare': 'off',
599
- // Iterator-helper rewrites churn test fakes with no runtime benefit.
600
- 'unicorn/prefer-iterator-helpers': 'off',
601
- 'unicorn/prefer-iterator-to-array': 'off',
602
- // String replacement with test-driven values is intentional in assertions.
603
- 'unicorn/no-unsafe-string-replacement': 'off',
604
- // Fake-D1 doubles await a DAO thunk and call straight onto the result.
605
- 'unicorn/no-await-expression-member': 'off',
606
- // `void promise` marks a deliberately unawaited promise in a test.
607
- 'sonarjs/void-use': 'off',
608
- // A test asserting request routing has to name `http://` hosts, and a
609
- // proxy test has to name a loopback upstream. Both are the subject
610
- // matter, not leaked configuration. `unicorn/prefer-https` must stay off
611
- // here and this is not a style preference: it rewrites `http://` to
612
- // `https://` *inside string literals*, and `--fix` applies it silently.
613
- 'sonarjs/no-clear-text-protocols': 'off',
614
- 'sonarjs/no-hardcoded-ip': 'off',
615
- 'unicorn/prefer-https': 'off',
616
- // sonarjs/assertions-in-tests fires false positives when test helpers
617
- // handle assertions indirectly.
618
- 'sonarjs/assertions-in-tests': 'off',
619
- // sonarjs/no-extra-arguments fires incorrectly on Vitest mock overloads.
620
- 'sonarjs/no-extra-arguments': 'off',
621
- // Union/inline types in test fakes are more readable than aliases.
622
- 'sonarjs/use-type-alias': 'off',
623
- // Alphabetical-sort rule fights deterministic fixture ordering.
624
- 'sonarjs/no-alphabetical-sort': 'off',
625
- // Repeated string literals in fixtures/assertions are clearer inline.
626
- 'sonarjs/no-duplicate-string': 'off',
627
- // Fake-D1 doubles break out of a nested loop to model a statement miss.
628
- 'unicorn/no-break-in-nested-loop': 'off',
629
- // Fixtures are naturally built with sort()/for…of over composed expressions.
630
- 'unicorn/no-array-sort': 'off',
631
- 'unicorn/no-unreadable-for-of-expression': 'off',
632
- 'unicorn/no-useless-template-literals': 'off',
633
- 'unicorn/no-declarations-before-early-exit': 'off',
634
- 'unicorn/prefer-includes-over-repeated-comparisons': 'off',
635
- 'sonarjs/prefer-specific-assertions': 'off',
636
- 'sonarjs/no-inverted-boolean-check': 'off',
637
- },
254
+ rules: asRules(TEST_RULES),
638
255
  },
639
256
  );
640
257
  }