@rexezuge/tooling 1.2.0 → 1.4.0

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.
Files changed (153) hide show
  1. package/README.md +66 -10
  2. package/dist/eslint-boundaries.d.ts +31 -7
  3. package/dist/eslint-boundaries.d.ts.map +1 -1
  4. package/dist/eslint-boundaries.js +1 -138
  5. package/dist/eslint-boundaries.js.map +7 -1
  6. package/dist/eslint-rules.js +1 -273
  7. package/dist/eslint-rules.js.map +7 -1
  8. package/dist/eslint.d.ts +12 -7
  9. package/dist/eslint.d.ts.map +1 -1
  10. package/dist/eslint.js +1 -189
  11. package/dist/eslint.js.map +7 -1
  12. package/dist/functions/pages-proxy.d.ts.map +1 -1
  13. package/dist/functions/pages-proxy.js +1 -131
  14. package/dist/functions/pages-proxy.js.map +7 -1
  15. package/dist/index.d.ts +20 -14
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -28
  18. package/dist/index.js.map +7 -1
  19. package/dist/scripts/backup/d1-target.d.ts +15 -5
  20. package/dist/scripts/backup/d1-target.d.ts.map +1 -1
  21. package/dist/scripts/backup/d1-target.js +1 -31
  22. package/dist/scripts/backup/d1-target.js.map +7 -1
  23. package/dist/scripts/backup/destination-config.d.ts +24 -8
  24. package/dist/scripts/backup/destination-config.d.ts.map +1 -1
  25. package/dist/scripts/backup/destination-config.js +1 -57
  26. package/dist/scripts/backup/destination-config.js.map +7 -1
  27. package/dist/scripts/backup/encrypt-backup.js +2 -97
  28. package/dist/scripts/backup/encrypt-backup.js.map +7 -1
  29. package/dist/scripts/backup/naming.d.ts +3 -1
  30. package/dist/scripts/backup/naming.d.ts.map +1 -1
  31. package/dist/scripts/backup/naming.js +1 -58
  32. package/dist/scripts/backup/naming.js.map +7 -1
  33. package/dist/scripts/check-god-files.d.ts +40 -14
  34. package/dist/scripts/check-god-files.d.ts.map +1 -1
  35. package/dist/scripts/check-god-files.js +2 -271
  36. package/dist/scripts/check-god-files.js.map +7 -1
  37. package/dist/scripts/ensure-spa-shell-stub.js +1 -29
  38. package/dist/scripts/ensure-spa-shell-stub.js.map +7 -1
  39. package/dist/scripts/init-secrets.d.ts +0 -16
  40. package/dist/scripts/init-secrets.d.ts.map +1 -1
  41. package/dist/scripts/init-secrets.js +2 -239
  42. package/dist/scripts/init-secrets.js.map +7 -1
  43. package/dist/scripts/lib/cli-args.d.ts.map +1 -1
  44. package/dist/scripts/lib/cli-args.js +1 -116
  45. package/dist/scripts/lib/cli-args.js.map +7 -1
  46. package/dist/scripts/lib/github-actions.js +3 -38
  47. package/dist/scripts/lib/github-actions.js.map +7 -1
  48. package/dist/scripts/lib/wrangler-table.d.ts.map +1 -1
  49. package/dist/scripts/lib/wrangler-table.js +2 -99
  50. package/dist/scripts/lib/wrangler-table.js.map +7 -1
  51. package/dist/scripts/migrations-lock.js +1 -44
  52. package/dist/scripts/migrations-lock.js.map +7 -1
  53. package/dist/scripts/prepare-wrangler-config.js +1 -49
  54. package/dist/scripts/prepare-wrangler-config.js.map +7 -1
  55. package/dist/scripts/spa-shell.d.ts +12 -4
  56. package/dist/scripts/spa-shell.d.ts.map +1 -1
  57. package/dist/scripts/spa-shell.js +3 -160
  58. package/dist/scripts/spa-shell.js.map +7 -1
  59. package/dist/scripts/validate-locales.d.ts +13 -5
  60. package/dist/scripts/validate-locales.d.ts.map +1 -1
  61. package/dist/scripts/validate-locales.js +4 -350
  62. package/dist/scripts/validate-locales.js.map +7 -1
  63. package/dist/scripts/verify-migrations.d.ts +27 -9
  64. package/dist/scripts/verify-migrations.d.ts.map +1 -1
  65. package/dist/scripts/verify-migrations.js +2 -312
  66. package/dist/scripts/verify-migrations.js.map +7 -1
  67. package/dist/scripts/verify-spa-shell.js +1 -52
  68. package/dist/scripts/verify-spa-shell.js.map +7 -1
  69. package/dist/scripts/wrangler-config/cli.js +3 -51
  70. package/dist/scripts/wrangler-config/cli.js.map +7 -1
  71. package/dist/scripts/wrangler-config/patches.d.ts +10 -4
  72. package/dist/scripts/wrangler-config/patches.d.ts.map +1 -1
  73. package/dist/scripts/wrangler-config/patches.js +4 -141
  74. package/dist/scripts/wrangler-config/patches.js.map +7 -1
  75. package/dist/scripts/wrangler-config/resources.d.ts +19 -7
  76. package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
  77. package/dist/scripts/wrangler-config/resources.js +1 -290
  78. package/dist/scripts/wrangler-config/resources.js.map +7 -1
  79. package/dist/scripts/wrangler-config/types.d.ts +24 -8
  80. package/dist/scripts/wrangler-config/types.d.ts.map +1 -1
  81. package/dist/scripts/wrangler-config/types.js +1 -49
  82. package/dist/scripts/wrangler-config/types.js.map +7 -1
  83. package/dist/test/integration-migrations.d.ts +29 -12
  84. package/dist/test/integration-migrations.d.ts.map +1 -1
  85. package/dist/test/integration-migrations.js +2 -171
  86. package/dist/test/integration-migrations.js.map +7 -1
  87. package/dist/test/mocks/cloudflare-workers.js +1 -90
  88. package/dist/test/mocks/cloudflare-workers.js.map +7 -1
  89. package/dist/vite.d.ts +5 -3
  90. package/dist/vite.d.ts.map +1 -1
  91. package/dist/vite.js +3 -125
  92. package/dist/vite.js.map +7 -1
  93. package/dist/vitest-aliases.d.ts +90 -0
  94. package/dist/vitest-aliases.d.ts.map +1 -0
  95. package/dist/vitest-aliases.js +1 -0
  96. package/dist/vitest-aliases.js.map +7 -0
  97. package/dist/vitest-integration.d.ts +96 -0
  98. package/dist/vitest-integration.d.ts.map +1 -0
  99. package/dist/vitest-integration.js +1 -0
  100. package/dist/vitest-integration.js.map +7 -0
  101. package/dist/vitest-repo.d.ts +154 -0
  102. package/dist/vitest-repo.d.ts.map +1 -0
  103. package/dist/vitest-repo.js +1 -0
  104. package/dist/vitest-repo.js.map +7 -0
  105. package/dist/vitest-web.d.ts +76 -19
  106. package/dist/vitest-web.d.ts.map +1 -1
  107. package/dist/vitest-web.js +1 -72
  108. package/dist/vitest-web.js.map +7 -1
  109. package/dist/vitest.d.ts +70 -19
  110. package/dist/vitest.d.ts.map +1 -1
  111. package/dist/vitest.js +1 -128
  112. package/dist/vitest.js.map +7 -1
  113. package/package.json +9 -3
  114. package/src/eslint-boundaries.ts +112 -11
  115. package/src/eslint.test.ts +40 -9
  116. package/src/eslint.ts +14 -9
  117. package/src/functions/pages-proxy.test.ts +3 -3
  118. package/src/functions/pages-proxy.ts +4 -2
  119. package/src/index.ts +23 -14
  120. package/src/scripts/backup/backup-rules.test.ts +4 -4
  121. package/src/scripts/backup/d1-target.ts +16 -6
  122. package/src/scripts/backup/destination-config.ts +27 -9
  123. package/src/scripts/backup/encrypt-backup.ts +12 -10
  124. package/src/scripts/backup/naming.ts +3 -1
  125. package/src/scripts/check-god-files.test.ts +19 -19
  126. package/src/scripts/check-god-files.ts +62 -33
  127. package/src/scripts/ensure-spa-shell-stub.ts +1 -1
  128. package/src/scripts/init-secrets.ts +20 -10
  129. package/src/scripts/lib/cli-args.ts +6 -3
  130. package/src/scripts/lib/wrangler-table.ts +5 -3
  131. package/src/scripts/migrations-lock.ts +2 -2
  132. package/src/scripts/prepare-wrangler-config.ts +3 -3
  133. package/src/scripts/spa-shell.test.ts +18 -18
  134. package/src/scripts/spa-shell.ts +26 -14
  135. package/src/scripts/validate-locales.test.ts +18 -18
  136. package/src/scripts/validate-locales.ts +43 -25
  137. package/src/scripts/verify-migrations.test.ts +8 -8
  138. package/src/scripts/verify-migrations.ts +47 -24
  139. package/src/scripts/verify-spa-shell.ts +1 -1
  140. package/src/scripts/wrangler-config/patches.ts +13 -5
  141. package/src/scripts/wrangler-config/resources.ts +34 -18
  142. package/src/scripts/wrangler-config/types.ts +24 -8
  143. package/src/test/integration-migrations.test.ts +7 -7
  144. package/src/test/integration-migrations.ts +33 -14
  145. package/src/vite.test.ts +25 -14
  146. package/src/vite.ts +5 -5
  147. package/src/vitest-aliases.test.ts +53 -0
  148. package/src/vitest-aliases.ts +125 -0
  149. package/src/vitest-factories.test.ts +127 -0
  150. package/src/vitest-integration.ts +118 -0
  151. package/src/vitest-repo.ts +269 -0
  152. package/src/vitest-web.ts +110 -28
  153. package/src/vitest.ts +96 -47
package/README.md CHANGED
@@ -18,7 +18,15 @@ convergence made — those headers are the documentation.
18
18
 
19
19
  ## 1. Config factories
20
20
 
21
- Four factories, four lines of consumer wiring each.
21
+ Four factories, four lines of consumer wiring each. The lint factory needs its
22
+ plugin set as peers — install them alongside the kit:
23
+
24
+ ```bash
25
+ pnpm add -D @rexezuge/tooling eslint typescript typescript-eslint vitest \
26
+ globals eslint-config-prettier eslint-plugin-prettier \
27
+ eslint-plugin-regexp eslint-plugin-sonarjs eslint-plugin-unicorn \
28
+ prettier jsonc-parser
29
+ ```
22
30
 
23
31
  ### ESLint
24
32
 
@@ -73,18 +81,21 @@ export default [
73
81
  import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';
74
82
 
75
83
  export default defineUnitVitestConfig({
76
- coverageInclude: ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'],
84
+ scope: '@my-app',
77
85
  thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },
78
86
  });
79
87
  ```
80
88
 
81
89
  v8 coverage with the converged include/exclude patterns (scripts, tests, barrels,
82
- generated files, type-only modules), `cloudflare:workers` / `cloudflare:sockets`
83
- aliased to the bundled Node stand-ins, and `test/integration/**` plus every
84
- `web-*` suite excluded so this config and the next one partition the suite rather
85
- than each running all of it. Vitest 4 removed `coverage.all`; an explicit
86
- `include` now reports files no test imported, which is the behaviour it was there
87
- to get.
90
+ generated files, type-only modules), the `@scope/* → src` workspace table (the
91
+ family superset — a repo without a domain package keeps the default harmlessly),
92
+ `cloudflare:workers` / `cloudflare:sockets` / `cloudflare:workflows` aliased to
93
+ the bundled Node stand-ins, `@rexezuge/*` kept inside Vite's pipeline
94
+ (`noExternal` — the kit ships bundler-style extensionless imports that Node's
95
+ resolver refuses), and `test/integration/**` plus every SPA shape excluded so
96
+ this config and the next one partition the suite rather than each running all
97
+ of it. Vitest 4 removed `coverage.all`; an explicit `include` now reports files
98
+ no test imported, which is the behaviour it was there to get.
88
99
 
89
100
  **Thresholds are a consumer argument, not a kit default.** A floor is a per-repo
90
101
  ratchet measured against that repo's suite; the kit cannot know a number, and
@@ -97,6 +108,7 @@ guessing one is how floors get lowered.
97
108
  import { defineWebVitestConfig } from '@rexezuge/tooling/vitest-web';
98
109
 
99
110
  export default defineWebVitestConfig({
111
+ scope: '@my-app',
100
112
  plugins: [react()],
101
113
  thresholds: { statements: 55, branches: 52, functions: 54, lines: 56 },
102
114
  });
@@ -105,8 +117,52 @@ export default defineWebVitestConfig({
105
117
  Converged from Durable-DAV-Router's and Mail-Otter's `vitest.web.config.mts`:
106
118
  jsdom for every file, `pool: 'threads'` bounded rather than a fork per file (a
107
119
  jsdom document per fork is what exhausts memory and dies with a bare "Worker
108
- exited unexpectedly"), and both suite-naming conventions collected
109
- (`test/**/web-*.test.{ts,tsx}` and `apps/web/**/*.test.{ts,tsx}`).
120
+ exited unexpectedly"), and every suite shape the family uses collected
121
+ (`test/web/**`, `test/**/web-*`, `apps/web/**`). `@/` and `~/` both mean the
122
+ SPA here (Mail-Otter's source imports through `@/`, Mail-Meow's and
123
+ CalDAV-Bridge's tests through `~/`); pass `environment: 'happy-dom'` for
124
+ CalDAV-Bridge's lighter DOM.
125
+
126
+ ### Vitest — the single-file `projects` composition
127
+
128
+ ```ts
129
+ // vitest.config.mts
130
+ import { defineRepoVitestConfig } from '@rexezuge/tooling/vitest-repo';
131
+
132
+ export default defineRepoVitestConfig({
133
+ scope: '@my-app',
134
+ web: { environment: 'happy-dom', plugins: [react()] },
135
+ thresholds: { statements: 87, branches: 77, functions: 88, lines: 90 },
136
+ });
137
+ ```
138
+
139
+ The same two halves as `projects` entries in one file (AWS-AccessBridge,
140
+ Mail-Meow, CalDAV-Bridge) with one root coverage gate. Each project repeats
141
+ the alias table — projects do not inherit the root `resolve` — with `@/` → API
142
+ on backend and `@/` + `~/` → SPA on web. Two-file repos keep the two factories
143
+ above; this one delegates to the same core.
144
+
145
+ ### Vitest — the integration suite
146
+
147
+ ```ts
148
+ // test/integration/vitest.config.mts
149
+ import { defineIntegrationVitestConfig } from '@rexezuge/tooling/vitest-integration';
150
+
151
+ export default defineIntegrationVitestConfig({
152
+ scope: '@my-app',
153
+ define: { __INTEGRATION_MIGRATION_SQL__: JSON.stringify(migrationSql) },
154
+ plugins: [cloudflareTest({ wrangler: { configPath: './test/integration/wrangler.test.jsonc' } })],
155
+ pool: cloudflarePool({ wrangler: { configPath: './test/integration/wrangler.test.jsonc' } }),
156
+ ssrNoExternal: ['hono', 'chanfana', '@my-app'],
157
+ });
158
+ ```
159
+
160
+ The workspace table without `cloudflare:*` mocks (the real runtime provides
161
+ them), defaulting to `test/integration/**/*.int.test.ts`. The workerd plugin,
162
+ pool and migration defines pass through untouched — importing them here would
163
+ make the tooling package undownloadable without workerd. CalDAV-Bridge's
164
+ `node:sqlite` suite passes `include: ['test/integration/**/*.test.ts']` and no
165
+ harness wiring.
110
166
 
111
167
  ### Vite — the SPA build
112
168
 
@@ -8,10 +8,20 @@ import type tseslint from 'typescript-eslint';
8
8
  * argues about — are their own module rather than the tail of a 640-line
9
9
  * config file.
10
10
  *
11
+ * Converged across all nine family repos: `provider-clients` (AWS-AccessBridge,
12
+ * CalDAV-Bridge, Mail-Meow, Mail-Otter), `webdav`/`dav-store` (Durable-DAV,
13
+ * Durable-DAV-Router, Edge-Sonic), `git-protocol`/`git-service` (Edge-Git).
14
+ * `media-tags`/`subsonic` (Edge-Sonic) carry no boundary block in their source
15
+ * repo — they are unconstrained utility leaves — so they have no layer here.
16
+ *
11
17
  * The table is data rather than inline blocks so the dynamic-`import()` guard
12
18
  * is generated from the same list: a rule that derived its banned set from
13
19
  * another rule's configuration would be a second source of truth for the layer
14
20
  * table, and that table is what the docs describe.
21
+ *
22
+ * The table is a superset: a repo without a domain package simply never imports
23
+ * it, so its ban never fires. A layer entry for a directory that does not exist
24
+ * in the consumer matches no file and costs nothing.
15
25
  */
16
26
  /**
17
27
  * The directories the boundary rules cover, in the canonical layout.
@@ -24,19 +34,33 @@ export declare const DEFAULT_PROJECT_DIRS: readonly string[];
24
34
  /**
25
35
  * One layer's ban list, as the repo-relative package suffixes it may not import.
26
36
  *
27
- * Converged from the four source stacks. `backend-data` and `backend-services`
28
- * appear in all four; `webdav`/`dav-store` are Durable-DAV's, `provider-clients`
29
- * is Mail-Meow's and AWS's. A layer only bans what exists in its repo, so the
37
+ * Converged from all nine family repos. `backend-data` and `backend-services`
38
+ * appear in all nine; `provider-clients` is AWS-AccessBridge's, CalDAV-Bridge's,
39
+ * Mail-Meow's and Mail-Otter's; `webdav`/`dav-store` are Durable-DAV's,
40
+ * Durable-DAV-Router's and Edge-Sonic's; `git-protocol`/`git-service` are
41
+ * Edge-Git's. A layer only bans what exists in its repo, so the
30
42
  * union is safe: a repo without `provider-clients` simply never imports it.
43
+ *
44
+ * One `dir` may appear in several entries (see `apps/api` below): each entry
45
+ * carries its own message and `allowTypeImports`, because the DAO ban allows
46
+ * type-only imports and the direct-client bans do not.
31
47
  */
32
48
  export interface LayerBan {
33
- /** Directory the rule is scoped to. */
49
+ /**
50
+ Directory the rule is scoped to.
51
+ */
34
52
  readonly dir: string;
35
- /** Package suffixes (relative to `scope`) that may not be imported from here. */
53
+ /**
54
+ Package suffixes (relative to `scope`) that may not be imported from here.
55
+ */
36
56
  readonly ban: readonly string[];
37
- /** Message shown when the rule fires. */
57
+ /**
58
+ Message shown when the rule fires.
59
+ */
38
60
  readonly message: string;
39
- /** Type-only imports are allowed, for the DAO boundary in `apps/api`. */
61
+ /**
62
+ Type-only imports are allowed, for the DAO boundary in `apps/api`.
63
+ */
40
64
  readonly allowTypeImports?: boolean;
41
65
  }
42
66
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"eslint-boundaries.d.ts","sourceRoot":"","sources":["../src/eslint-boundaries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C;;;;;;;;;;;;;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AC,OAAO,EAAE,MAAM,CAAC;IACzB;;MAEE;IACF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,QAAQ,EAAE,CA2H5D;AAED;;;;GAIG;AACH,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,GAAG,WAAW,EAAE,CAgB1E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,GAAG,WAAW,EAAE,CAajF"}
@@ -1,138 +1 @@
1
- /**
2
- * The layer table behind the repo lint config's import boundaries.
3
- *
4
- * Provenance: the seven `no-restricted-imports` blocks in Durable-DAV's
5
- * `eslint.config.mjs`, with `@durable-dav/` replaced by the caller's scope.
6
- * Extracted from `eslint.ts` so the boundary rules — the part a repo actually
7
- * argues about — are their own module rather than the tail of a 640-line
8
- * config file.
9
- *
10
- * The table is data rather than inline blocks so the dynamic-`import()` guard
11
- * is generated from the same list: a rule that derived its banned set from
12
- * another rule's configuration would be a second source of truth for the layer
13
- * table, and that table is what the docs describe.
14
- */
15
- /**
16
- * The directories the boundary rules cover, in the canonical layout.
17
- *
18
- * Kept here, beside the table it scopes: `defineRepoLintConfig` filters the
19
- * canonical layers by `projectDirs`, and a reader of the layer table should not
20
- * have to open the config assembly to learn which directories it covers.
21
- */
22
- export const DEFAULT_PROJECT_DIRS = [
23
- 'packages/shared',
24
- 'packages/backend-errors',
25
- 'packages/backend-runtime',
26
- 'packages/backend-data',
27
- 'packages/backend-services',
28
- 'apps/api',
29
- 'apps/background',
30
- 'apps/web',
31
- ];
32
- /**
33
- * The layer table, parameterized by `scope`.
34
- */
35
- export function layerBans(scope) {
36
- const at = (name) => `${scope}/${name}`;
37
- return [
38
- {
39
- dir: 'packages/shared',
40
- ban: [at('*')],
41
- message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,
42
- },
43
- {
44
- dir: 'packages/backend-errors',
45
- ban: [at('*')],
46
- message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,
47
- },
48
- {
49
- dir: 'packages/backend-runtime',
50
- ban: [at('backend-data'), at('webdav'), at('backend-services'), at('api'), at('background')],
51
- message: 'backend-runtime must not import from a higher layer',
52
- },
53
- {
54
- dir: 'packages/backend-data',
55
- ban: [at('backend-runtime'), at('webdav'), at('backend-services'), at('api'), at('background')],
56
- message: 'backend-data must not import from a higher layer',
57
- },
58
- {
59
- dir: 'packages/backend-services',
60
- ban: [at('api'), at('background')],
61
- message: 'backend-services must not import from apps',
62
- },
63
- {
64
- dir: 'apps/api',
65
- ban: [at('backend-data/dao'), at('backend-data')],
66
- allowTypeImports: true,
67
- message: 'apps/api must not import DAOs or backend-data values directly; use backend-services instead',
68
- },
69
- {
70
- dir: 'apps/background',
71
- ban: [at('api')],
72
- message: 'apps/background must not import from apps/api',
73
- },
74
- // The browser half, and the only layer that bans the namespace wholesale
75
- // rather than a list of siblings: a backend package imported by the SPA
76
- // typechecks and then fails at bundle time, with the error pointing at the
77
- // bundler rather than at the boundary. Edge-Sonic is the source; the others had
78
- // no block for it at all, which is how their layer table's "may import: the
79
- // browser" was a convention instead of a gate.
80
- {
81
- dir: 'apps/web',
82
- ban: [at('*')],
83
- message: `${at('apps/web')} ships zero backend dependencies — this module is the SPA's own copy`,
84
- },
85
- ];
86
- }
87
- /**
88
- * The `no-restricted-imports` entries for one layer.
89
- *
90
- * Written as `group` patterns rather than exact `paths`, so `@myapp/backend-data`
91
- * and `@myapp/backend-data/dao` are both caught by one entry. `allowTypeImports`
92
- * is passed through only where the source repos set it, because `apps/api`
93
- * legitimately types its filters and models against DAO shapes.
94
- */
95
- export function restrictedImports(bans) {
96
- return bans.map(({ dir, ban, message, allowTypeImports }) => ({
97
- files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],
98
- rules: {
99
- 'no-restricted-imports': [
100
- 'error',
101
- {
102
- patterns: ban.map((group) => ({
103
- group: [group, `${group}/*`],
104
- message,
105
- ...(allowTypeImports === true && { allowTypeImports: true }),
106
- })),
107
- },
108
- ],
109
- },
110
- }));
111
- }
112
- /**
113
- * The dynamic-`import()` guard, generated from the same table.
114
- *
115
- * `no-restricted-imports` reads `ImportDeclaration` nodes only; a dynamic
116
- * `import()` is an `ImportExpression`, and this ESLint version does not report it
117
- * under that rule at all. Edge-Sonic verified this rather than assumed it — a
118
- * static import of a restricted specifier from the same file is an `error`, and
119
- * the identical specifier reached through `await import(...)` is silent. That
120
- * hole was load-bearing there: the credential path reached a banned module
121
- * through it. `no-restricted-syntax` sees `ImportExpression`, so the boundary is
122
- * stated a second way.
123
- */
124
- export function restrictedDynamicImports(bans) {
125
- return bans.map(({ dir, ban, message }) => ({
126
- files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],
127
- rules: {
128
- 'no-restricted-syntax': [
129
- 'error',
130
- ...ban.map((specifier) => ({
131
- selector: `ImportExpression[source.type='Literal'][source.value=/^${specifier.replaceAll('/', '\\/')}/]`,
132
- 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}`,
133
- })),
134
- ],
135
- },
136
- }));
137
- }
138
- //# sourceMappingURL=eslint-boundaries.js.map
1
+ const n=["packages/shared","packages/backend-errors","packages/backend-runtime","packages/backend-data","packages/provider-clients","packages/webdav","packages/dav-store","packages/git-protocol","packages/git-service","packages/backend-services","apps/api","apps/background","apps/web"];function o(a){const e=s=>`${a}/${s}`;return[{dir:"packages/shared",ban:[e("*")],message:`${a} packages must not import from other ${a} packages \u2014 this is a zero-dependency base layer`},{dir:"packages/backend-errors",ban:[e("*")],message:`${a} packages must not import from other ${a} packages \u2014 this is a zero-dependency base layer`},{dir:"packages/backend-runtime",ban:[e("backend-data"),e("provider-clients"),e("webdav"),e("dav-store"),e("git-protocol"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"backend-runtime must not import from a higher layer"},{dir:"packages/backend-data",ban:[e("backend-runtime"),e("provider-clients"),e("webdav"),e("dav-store"),e("git-protocol"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"backend-data must not import from a higher layer"},{dir:"packages/provider-clients",ban:[e("backend-data"),e("backend-runtime"),e("backend-services"),e("api"),e("background")],message:"provider-clients must not import DAOs from backend-data"},{dir:"packages/webdav",ban:[e("backend-data"),e("backend-runtime"),e("dav-store"),e("backend-services"),e("api"),e("background")],message:"webdav must not import DAOs from backend-data"},{dir:"packages/git-protocol",ban:[e("backend-data"),e("backend-runtime"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"git-protocol must not import DAOs from backend-data"},{dir:"packages/dav-store",ban:[e("backend-services"),e("api"),e("background")],message:"dav-store must not import from backend-services (higher layer)"},{dir:"packages/git-service",ban:[e("backend-services"),e("api"),e("background")],message:"git-service must not import from backend-services (higher layer)"},{dir:"packages/backend-services",ban:[e("api"),e("background")],message:"backend-services must not import from apps"},{dir:"apps/api",ban:[e("backend-data/dao"),e("backend-data")],allowTypeImports:!0,message:"apps/api must not import DAOs or backend-data values directly; use backend-services instead (type-only imports are allowed)"},{dir:"apps/api",ban:[e("provider-clients")],message:`apps/api must not import provider-clients directly; use ${a}/backend-services instead`},{dir:"apps/api",ban:[e("dav-store")],message:`apps/api must not import dav-store directly; use ${a}/webdav + DO RPC via ${a}/background instead`},{dir:"apps/api",ban:[e("git-service")],message:`apps/api must not import git-service directly; use ${a}/git-protocol + DO RPC via ${a}/background instead`},{dir:"apps/background",ban:[e("api")],message:"apps/background must not import from apps/api"},{dir:"apps/web",ban:[e("*")],message:`${e("apps/web")} ships zero backend dependencies \u2014 this module is the SPA's own copy`}]}function c(a){return a.map(({dir:e,ban:s,message:t,allowTypeImports:r})=>({files:[`${e}/**/*.{ts,js,mts,cts,mjs,cjs}`],rules:{"no-restricted-imports":["error",{patterns:s.map(i=>({group:[i,`${i}/*`],message:t,...r===!0&&{allowTypeImports:!0}}))}]}}))}function d(a){return a.map(({dir:e,ban:s,message:t})=>({files:[`${e}/**/*.{ts,js,mts,cts,mjs,cjs}`],rules:{"no-restricted-syntax":["error",...s.map(r=>({selector:`ImportExpression[source.type='Literal'][source.value=/^${r.replaceAll("/",String.raw`\/`)}/]`,message:`A dynamic import() is not covered by no-restricted-imports, so this layer reaches \`${r}\` through the one syntax that gate does not see. Both say no: ${t}`}))]}}))}export{n as DEFAULT_PROJECT_DIRS,o as layerBans,d as restrictedDynamicImports,c as restrictedImports};
@@ -1 +1,7 @@
1
- {"version":3,"file":"eslint-boundaries.js","sourceRoot":"","sources":["../src/eslint-boundaries.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,iBAAiB;IACjB,yBAAyB;IACzB,0BAA0B;IAC1B,uBAAuB;IACvB,2BAA2B;IAC3B,UAAU;IACV,iBAAiB;IACjB,UAAU;CACX,CAAC;AAqBF;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,MAAM,EAAE,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;IACxD,OAAO;QACL;YACE,GAAG,EAAE,iBAAiB;YACtB,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YACd,OAAO,EAAE,GAAG,KAAK,wCAAwC,KAAK,kDAAkD;SACjH;QACD;YACE,GAAG,EAAE,yBAAyB;YAC9B,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YACd,OAAO,EAAE,GAAG,KAAK,wCAAwC,KAAK,kDAAkD;SACjH;QACD;YACE,GAAG,EAAE,0BAA0B;YAC/B,GAAG,EAAE,CAAC,EAAE,CAAC,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AAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5D,KAAK,EAAE,CAAC,GAAG,GAAG,+BAA+B,CAAC;QAC9C,KAAK,EAAE;YACL,uBAAuB,EAAE;gBACvB,OAAO;gBACP;oBACE,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;wBAC5B,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;wBAC5B,OAAO;wBACP,GAAG,CAAC,gBAAgB,KAAK,IAAI,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;qBAC7D,CAAC,CAAC;iBACJ;aACF;SACF;KACF,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAyB;IAChE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,KAAK,EAAE,CAAC,GAAG,GAAG,+BAA+B,CAAC;QAC9C,KAAK,EAAE;YACL,sBAAsB,EAAE;gBACtB,OAAO;gBACP,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;oBACzB,QAAQ,EAAE,0DAA0D,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI;oBACxG,OAAO,EAAE,uFAAuF,SAAS,kEAAkE,OAAO,EAAE;iBACrL,CAAC,CAAC;aACJ;SACF;KACF,CAAC,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type tseslint from 'typescript-eslint';\n\n/**\n * The layer table behind the repo lint config's import boundaries.\n *\n * Provenance: the seven `no-restricted-imports` blocks in Durable-DAV's\n * `eslint.config.mjs`, with `@durable-dav/` replaced by the caller's scope.\n * Extracted from `eslint.ts` so the boundary rules — the part a repo actually\n * argues about — are their own module rather than the tail of a 640-line\n * config file.\n *\n * The table is data rather than inline blocks so the dynamic-`import()` guard\n * is generated from the same list: a rule that derived its banned set from\n * another rule's configuration would be a second source of truth for the layer\n * table, and that table is what the docs describe.\n */\n\n/**\n * The directories the boundary rules cover, in the canonical layout.\n *\n * Kept here, beside the table it scopes: `defineRepoLintConfig` filters the\n * canonical layers by `projectDirs`, and a reader of the layer table should not\n * have to open the config assembly to learn which directories it covers.\n */\nexport const DEFAULT_PROJECT_DIRS: readonly string[] = [\n 'packages/shared',\n 'packages/backend-errors',\n 'packages/backend-runtime',\n 'packages/backend-data',\n 'packages/backend-services',\n 'apps/api',\n 'apps/background',\n 'apps/web',\n];\n\n/**\n * One layer's ban list, as the repo-relative package suffixes it may not import.\n *\n * Converged from the four source stacks. `backend-data` and `backend-services`\n * appear in all four; `webdav`/`dav-store` are Durable-DAV's, `provider-clients`\n * is Mail-Meow's and AWS's. A layer only bans what exists in its repo, so the\n * union is safe: a repo without `provider-clients` simply never imports it.\n */\nexport interface LayerBan {\n /** Directory the rule is scoped to. */\n readonly dir: string;\n /** Package suffixes (relative to `scope`) that may not be imported from here. */\n readonly ban: readonly string[];\n /** Message shown when the rule fires. */\n readonly message: string;\n /** Type-only imports are allowed, for the DAO boundary in `apps/api`. */\n readonly allowTypeImports?: boolean;\n}\n\n/**\n * The layer table, parameterized by `scope`.\n */\nexport function layerBans(scope: string): readonly LayerBan[] {\n const at = (name: string): string => `${scope}/${name}`;\n return [\n {\n dir: 'packages/shared',\n ban: [at('*')],\n message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,\n },\n {\n dir: 'packages/backend-errors',\n ban: [at('*')],\n message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,\n },\n {\n dir: 'packages/backend-runtime',\n ban: [at('backend-data'), at('webdav'), at('backend-services'), at('api'), at('background')],\n message: 'backend-runtime must not import from a higher layer',\n },\n {\n dir: 'packages/backend-data',\n ban: [at('backend-runtime'), at('webdav'), at('backend-services'), at('api'), at('background')],\n message: 'backend-data must not import from a higher layer',\n },\n {\n dir: 'packages/backend-services',\n ban: [at('api'), at('background')],\n message: 'backend-services must not import from apps',\n },\n {\n dir: 'apps/api',\n ban: [at('backend-data/dao'), at('backend-data')],\n allowTypeImports: true,\n message: 'apps/api must not import DAOs or backend-data values directly; use backend-services instead',\n },\n {\n dir: 'apps/background',\n ban: [at('api')],\n message: 'apps/background must not import from apps/api',\n },\n // The browser half, and the only layer that bans the namespace wholesale\n // rather than a list of siblings: a backend package imported by the SPA\n // typechecks and then fails at bundle time, with the error pointing at the\n // bundler rather than at the boundary. Edge-Sonic is the source; the others had\n // no block for it at all, which is how their layer table's \"may import: the\n // browser\" was a convention instead of a gate.\n {\n dir: 'apps/web',\n ban: [at('*')],\n message: `${at('apps/web')} ships zero backend dependencies — this module is the SPA's own copy`,\n },\n ];\n}\n\n/**\n * One argument to `tseslint.config()`, named here so the boundary builders\n * return the assembled type rather than a lookalike the assembly then has to\n * be argued into accepting.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * The `no-restricted-imports` entries for one layer.\n *\n * Written as `group` patterns rather than exact `paths`, so `@myapp/backend-data`\n * and `@myapp/backend-data/dao` are both caught by one entry. `allowTypeImports`\n * is passed through only where the source repos set it, because `apps/api`\n * legitimately types its filters and models against DAO shapes.\n */\nexport function restrictedImports(bans: readonly LayerBan[]): ConfigInput[] {\n return bans.map(({ dir, ban, message, allowTypeImports }) => ({\n files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],\n rules: {\n 'no-restricted-imports': [\n 'error',\n {\n patterns: ban.map((group) => ({\n group: [group, `${group}/*`],\n message,\n ...(allowTypeImports === true && { allowTypeImports: true }),\n })),\n },\n ],\n },\n }));\n}\n\n/**\n * The dynamic-`import()` guard, generated from the same table.\n *\n * `no-restricted-imports` reads `ImportDeclaration` nodes only; a dynamic\n * `import()` is an `ImportExpression`, and this ESLint version does not report it\n * under that rule at all. Edge-Sonic verified this rather than assumed it — a\n * static import of a restricted specifier from the same file is an `error`, and\n * the identical specifier reached through `await import(...)` is silent. That\n * hole was load-bearing there: the credential path reached a banned module\n * through it. `no-restricted-syntax` sees `ImportExpression`, so the boundary is\n * stated a second way.\n */\nexport function restrictedDynamicImports(bans: readonly LayerBan[]): ConfigInput[] {\n return bans.map(({ dir, ban, message }) => ({\n files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],\n rules: {\n 'no-restricted-syntax': [\n 'error',\n ...ban.map((specifier) => ({\n selector: `ImportExpression[source.type='Literal'][source.value=/^${specifier.replaceAll('/', '\\\\/')}/]`,\n 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}`,\n })),\n ],\n },\n }));\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/eslint-boundaries.ts"],
4
+ "sourcesContent": ["import type tseslint from 'typescript-eslint';\n\n/**\n * The layer table behind the repo lint config's import boundaries.\n *\n * Provenance: the seven `no-restricted-imports` blocks in Durable-DAV's\n * `eslint.config.mjs`, with `@durable-dav/` replaced by the caller's scope.\n * Extracted from `eslint.ts` so the boundary rules — the part a repo actually\n * argues about — are their own module rather than the tail of a 640-line\n * config file.\n *\n * Converged across all nine family repos: `provider-clients` (AWS-AccessBridge,\n * CalDAV-Bridge, Mail-Meow, Mail-Otter), `webdav`/`dav-store` (Durable-DAV,\n * Durable-DAV-Router, Edge-Sonic), `git-protocol`/`git-service` (Edge-Git).\n * `media-tags`/`subsonic` (Edge-Sonic) carry no boundary block in their source\n * repo — they are unconstrained utility leaves — so they have no layer here.\n *\n * The table is data rather than inline blocks so the dynamic-`import()` guard\n * is generated from the same list: a rule that derived its banned set from\n * another rule's configuration would be a second source of truth for the layer\n * table, and that table is what the docs describe.\n *\n * The table is a superset: a repo without a domain package simply never imports\n * it, so its ban never fires. A layer entry for a directory that does not exist\n * in the consumer matches no file and costs nothing.\n */\n\n/**\n * The directories the boundary rules cover, in the canonical layout.\n *\n * Kept here, beside the table it scopes: `defineRepoLintConfig` filters the\n * canonical layers by `projectDirs`, and a reader of the layer table should not\n * have to open the config assembly to learn which directories it covers.\n */\nexport const DEFAULT_PROJECT_DIRS: readonly string[] = [\n 'packages/shared',\n 'packages/backend-errors',\n 'packages/backend-runtime',\n 'packages/backend-data',\n 'packages/provider-clients',\n 'packages/webdav',\n 'packages/dav-store',\n 'packages/git-protocol',\n 'packages/git-service',\n 'packages/backend-services',\n 'apps/api',\n 'apps/background',\n 'apps/web',\n];\n\n/**\n * One layer's ban list, as the repo-relative package suffixes it may not import.\n *\n * Converged from all nine family repos. `backend-data` and `backend-services`\n * appear in all nine; `provider-clients` is AWS-AccessBridge's, CalDAV-Bridge's,\n * Mail-Meow's and Mail-Otter's; `webdav`/`dav-store` are Durable-DAV's,\n * Durable-DAV-Router's and Edge-Sonic's; `git-protocol`/`git-service` are\n * Edge-Git's. A layer only bans what exists in its repo, so the\n * union is safe: a repo without `provider-clients` simply never imports it.\n *\n * One `dir` may appear in several entries (see `apps/api` below): each entry\n * carries its own message and `allowTypeImports`, because the DAO ban allows\n * type-only imports and the direct-client bans do not.\n */\nexport interface LayerBan {\n /**\n Directory the rule is scoped to.\n */\n readonly dir: string;\n /**\n Package suffixes (relative to `scope`) that may not be imported from here.\n */\n readonly ban: readonly string[];\n /**\n Message shown when the rule fires.\n */\n readonly message: string;\n /**\n Type-only imports are allowed, for the DAO boundary in `apps/api`.\n */\n readonly allowTypeImports?: boolean;\n}\n\n/**\n * The layer table, parameterized by `scope`.\n */\nexport function layerBans(scope: string): readonly LayerBan[] {\n const at = (name: string): string => `${scope}/${name}`;\n return [\n {\n dir: 'packages/shared',\n ban: [at('*')],\n message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,\n },\n {\n dir: 'packages/backend-errors',\n ban: [at('*')],\n message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,\n },\n {\n dir: 'packages/backend-runtime',\n ban: [\n at('backend-data'),\n at('provider-clients'),\n at('webdav'),\n at('dav-store'),\n at('git-protocol'),\n at('git-service'),\n at('backend-services'),\n at('api'),\n at('background'),\n ],\n message: 'backend-runtime must not import from a higher layer',\n },\n {\n dir: 'packages/backend-data',\n ban: [\n at('backend-runtime'),\n at('provider-clients'),\n at('webdav'),\n at('dav-store'),\n at('git-protocol'),\n at('git-service'),\n at('backend-services'),\n at('api'),\n at('background'),\n ],\n message: 'backend-data must not import from a higher layer',\n },\n // Domain protocol layers (layer 2, beside backend-data): each bans the DAO\n // layer, the runtime, its store counterpart where it has one, the service\n // layer and the apps. Sources: provider-clients (AWS-AccessBridge,\n // Mail-Meow), webdav (Durable-DAV, Edge-Sonic), git-protocol (Edge-Git).\n {\n dir: 'packages/provider-clients',\n ban: [at('backend-data'), at('backend-runtime'), at('backend-services'), at('api'), at('background')],\n message: 'provider-clients must not import DAOs from backend-data',\n },\n {\n dir: 'packages/webdav',\n ban: [at('backend-data'), at('backend-runtime'), at('dav-store'), at('backend-services'), at('api'), at('background')],\n message: 'webdav must not import DAOs from backend-data',\n },\n {\n dir: 'packages/git-protocol',\n ban: [at('backend-data'), at('backend-runtime'), at('git-service'), at('backend-services'), at('api'), at('background')],\n message: 'git-protocol must not import DAOs from backend-data',\n },\n // Domain store layers (layer 2-3): only layers 0-2, never services or apps.\n // Sources: dav-store (Durable-DAV), git-service (Edge-Git).\n {\n dir: 'packages/dav-store',\n ban: [at('backend-services'), at('api'), at('background')],\n message: 'dav-store must not import from backend-services (higher layer)',\n },\n {\n dir: 'packages/git-service',\n ban: [at('backend-services'), at('api'), at('background')],\n message: 'git-service must not import from backend-services (higher layer)',\n },\n {\n dir: 'packages/backend-services',\n ban: [at('api'), at('background')],\n message: 'backend-services must not import from apps',\n },\n {\n dir: 'apps/api',\n ban: [at('backend-data/dao'), at('backend-data')],\n allowTypeImports: true,\n message:\n 'apps/api must not import DAOs or backend-data values directly; use backend-services instead (type-only imports are allowed)',\n },\n // Direct-client bans: one entry per client package so each message names\n // the correct alternative. A repo holds at most one of these packages, so\n // the other two never fire. Sources: provider-clients (AWS-AccessBridge,\n // Mail-Meow, Mail-Otter, CalDAV-Bridge), dav-store (Durable-DAV),\n // git-service (Edge-Git).\n {\n dir: 'apps/api',\n ban: [at('provider-clients')],\n message: `apps/api must not import provider-clients directly; use ${scope}/backend-services instead`,\n },\n {\n dir: 'apps/api',\n ban: [at('dav-store')],\n message: `apps/api must not import dav-store directly; use ${scope}/webdav + DO RPC via ${scope}/background instead`,\n },\n {\n dir: 'apps/api',\n ban: [at('git-service')],\n message: `apps/api must not import git-service directly; use ${scope}/git-protocol + DO RPC via ${scope}/background instead`,\n },\n {\n dir: 'apps/background',\n ban: [at('api')],\n message: 'apps/background must not import from apps/api',\n },\n // The browser half, and the only layer that bans the namespace wholesale\n // rather than a list of siblings: a backend package imported by the SPA\n // typechecks and then fails at bundle time, with the error pointing at the\n // bundler rather than at the boundary. Edge-Sonic is the source; the others had\n // no block for it at all, which is how their layer table's \"may import: the\n // browser\" was a convention instead of a gate.\n {\n dir: 'apps/web',\n ban: [at('*')],\n message: `${at('apps/web')} ships zero backend dependencies — this module is the SPA's own copy`,\n },\n ];\n}\n\n/**\n * One argument to `tseslint.config()`, named here so the boundary builders\n * return the assembled type rather than a lookalike the assembly then has to\n * be argued into accepting.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * The `no-restricted-imports` entries for one layer.\n *\n * Written as `group` patterns rather than exact `paths`, so `@myapp/backend-data`\n * and `@myapp/backend-data/dao` are both caught by one entry. `allowTypeImports`\n * is passed through only where the source repos set it, because `apps/api`\n * legitimately types its filters and models against DAO shapes.\n */\nexport function restrictedImports(bans: readonly LayerBan[]): ConfigInput[] {\n return bans.map(({ dir, ban, message, allowTypeImports }) => ({\n files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],\n rules: {\n 'no-restricted-imports': [\n 'error',\n {\n patterns: ban.map((group) => ({\n group: [group, `${group}/*`],\n message,\n ...(allowTypeImports === true && { allowTypeImports: true }),\n })),\n },\n ],\n },\n }));\n}\n\n/**\n * The dynamic-`import()` guard, generated from the same table.\n *\n * `no-restricted-imports` reads `ImportDeclaration` nodes only; a dynamic\n * `import()` is an `ImportExpression`, and this ESLint version does not report it\n * under that rule at all. Edge-Sonic verified this rather than assumed it — a\n * static import of a restricted specifier from the same file is an `error`, and\n * the identical specifier reached through `await import(...)` is silent. That\n * hole was load-bearing there: the credential path reached a banned module\n * through it. `no-restricted-syntax` sees `ImportExpression`, so the boundary is\n * stated a second way.\n */\nexport function restrictedDynamicImports(bans: readonly LayerBan[]): ConfigInput[] {\n return bans.map(({ dir, ban, message }) => ({\n files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],\n rules: {\n 'no-restricted-syntax': [\n 'error',\n ...ban.map((specifier) => ({\n selector: `ImportExpression[source.type='Literal'][source.value=/^${specifier.replaceAll('/', String.raw`\\/`)}/]`,\n 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}`,\n })),\n ],\n },\n }));\n}\n"],
5
+ "mappings": "AAkCO,MAAMA,EAA0C,CACrD,kBACA,0BACA,2BACA,wBACA,4BACA,kBACA,qBACA,wBACA,uBACA,4BACA,WACA,kBACA,YAuCI,SAAUC,EAAUC,EAAa,CACrC,MAAMC,EAAMC,GAAyB,GAAGF,CAAK,IAAIE,CAAI,GACrD,MAAO,CACL,CACE,IAAK,kBACL,IAAK,CAACD,EAAG,GAAG,CAAC,EACb,QAAS,GAAGD,CAAK,wCAAwCA,CAAK,yDAEhE,CACE,IAAK,0BACL,IAAK,CAACC,EAAG,GAAG,CAAC,EACb,QAAS,GAAGD,CAAK,wCAAwCA,CAAK,yDAEhE,CACE,IAAK,2BACL,IAAK,CACHC,EAAG,cAAc,EACjBA,EAAG,kBAAkB,EACrBA,EAAG,QAAQ,EACXA,EAAG,WAAW,EACdA,EAAG,cAAc,EACjBA,EAAG,aAAa,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AC5B,QAAS,2DAA2DD,CAAK,6BAE3E,CACE,IAAK,WACL,IAAK,CAACC,EAAG,WAAW,CAAC,EACrB,QAAS,oDAAoDD,CAAK,wBAAwBA,CAAK,uBAEjG,CACE,IAAK,WACL,IAAK,CAACC,EAAG,aAAa,CAAC,EACvB,QAAS,sDAAsDD,CAAK,8BAA8BA,CAAK,uBAEzG,CACE,IAAK,kBACL,IAAK,CAACC,EAAG,KAAK,CAAC,EACf,QAAS,iDAQX,CACE,IAAK,WACL,IAAK,CAACA,EAAG,GAAG,CAAC,EACb,QAAS,GAAGA,EAAG,UAAU,CAAC,6EAGhC,CAiBM,SAAUE,EAAkBC,EAAyB,CACzD,OAAOA,EAAK,IAAI,CAAC,CAAE,IAAAC,EAAK,IAAAC,EAAK,QAAAC,EAAS,iBAAAC,CAAgB,KAAQ,CAC5D,MAAO,CAAC,GAAGH,CAAG,+BAA+B,EAC7C,MAAO,CACL,wBAAyB,CACvB,QACA,CACE,SAAUC,EAAI,IAAKG,IAAW,CAC5B,MAAO,CAACA,EAAO,GAAGA,CAAK,IAAI,EAC3B,QAAAF,EACA,GAAIC,IAAqB,IAAQ,CAAE,iBAAkB,EAAI,GACzD,MAIR,CACJ,CAcM,SAAUE,EAAyBN,EAAyB,CAChE,OAAOA,EAAK,IAAI,CAAC,CAAE,IAAAC,EAAK,IAAAC,EAAK,QAAAC,CAAO,KAAQ,CAC1C,MAAO,CAAC,GAAGF,CAAG,+BAA+B,EAC7C,MAAO,CACL,uBAAwB,CACtB,QACA,GAAGC,EAAI,IAAKK,IAAe,CACzB,SAAU,0DAA0DA,EAAU,WAAW,IAAK,OAAO,OAAO,CAAC,KAC7G,QAAS,uFAAuFA,CAAS,kEAAkEJ,CAAO,IAClL,KAGN,CACJ",
6
+ "names": ["DEFAULT_PROJECT_DIRS", "layerBans", "scope", "at", "name", "restrictedImports", "bans", "dir", "ban", "message", "allowTypeImports", "group", "restrictedDynamicImports", "specifier"]
7
+ }