@rexezuge/tooling 1.2.0 → 1.3.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.
- package/README.md +66 -10
- package/dist/eslint-boundaries.d.ts +19 -3
- package/dist/eslint-boundaries.d.ts.map +1 -1
- package/dist/eslint-boundaries.js +89 -3
- package/dist/eslint-boundaries.js.map +1 -1
- package/dist/eslint.d.ts +12 -7
- package/dist/eslint.d.ts.map +1 -1
- package/dist/eslint.js +13 -8
- package/dist/eslint.js.map +1 -1
- package/dist/index.d.ts +20 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/scripts/backup/d1-target.js +1 -1
- package/dist/scripts/backup/d1-target.js.map +1 -1
- package/dist/scripts/backup/encrypt-backup.js +2 -2
- package/dist/scripts/backup/encrypt-backup.js.map +1 -1
- package/dist/scripts/check-god-files.js +2 -2
- package/dist/scripts/check-god-files.js.map +1 -1
- package/dist/scripts/ensure-spa-shell-stub.js +1 -1
- package/dist/scripts/ensure-spa-shell-stub.js.map +1 -1
- package/dist/scripts/init-secrets.d.ts +1 -1
- package/dist/scripts/init-secrets.d.ts.map +1 -1
- package/dist/scripts/init-secrets.js +3 -3
- package/dist/scripts/init-secrets.js.map +1 -1
- package/dist/scripts/migrations-lock.js +1 -1
- package/dist/scripts/migrations-lock.js.map +1 -1
- package/dist/scripts/prepare-wrangler-config.js +3 -3
- package/dist/scripts/prepare-wrangler-config.js.map +1 -1
- package/dist/scripts/verify-spa-shell.js +1 -1
- package/dist/scripts/verify-spa-shell.js.map +1 -1
- package/dist/scripts/wrangler-config/patches.d.ts +1 -1
- package/dist/scripts/wrangler-config/patches.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/patches.js +1 -1
- package/dist/scripts/wrangler-config/patches.js.map +1 -1
- package/dist/scripts/wrangler-config/resources.d.ts +1 -1
- package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/resources.js +4 -4
- package/dist/scripts/wrangler-config/resources.js.map +1 -1
- package/dist/vitest-aliases.d.ts +90 -0
- package/dist/vitest-aliases.d.ts.map +1 -0
- package/dist/vitest-aliases.js +81 -0
- package/dist/vitest-aliases.js.map +1 -0
- package/dist/vitest-integration.d.ts +96 -0
- package/dist/vitest-integration.d.ts.map +1 -0
- package/dist/vitest-integration.js +64 -0
- package/dist/vitest-integration.js.map +1 -0
- package/dist/vitest-repo.d.ts +154 -0
- package/dist/vitest-repo.d.ts.map +1 -0
- package/dist/vitest-repo.js +146 -0
- package/dist/vitest-repo.js.map +1 -0
- package/dist/vitest-web.d.ts +76 -19
- package/dist/vitest-web.d.ts.map +1 -1
- package/dist/vitest-web.js +62 -25
- package/dist/vitest-web.js.map +1 -1
- package/dist/vitest.d.ts +70 -19
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +42 -37
- package/dist/vitest.js.map +1 -1
- package/package.json +8 -2
- package/src/eslint-boundaries.ts +99 -6
- package/src/eslint.test.ts +22 -1
- package/src/eslint.ts +14 -9
- package/src/functions/pages-proxy.test.ts +2 -2
- package/src/index.ts +23 -14
- package/src/scripts/backup/backup-rules.test.ts +3 -3
- package/src/scripts/backup/d1-target.ts +1 -1
- package/src/scripts/backup/encrypt-backup.ts +2 -2
- package/src/scripts/check-god-files.test.ts +1 -1
- package/src/scripts/check-god-files.ts +2 -2
- package/src/scripts/ensure-spa-shell-stub.ts +1 -1
- package/src/scripts/init-secrets.ts +3 -3
- package/src/scripts/migrations-lock.ts +1 -1
- package/src/scripts/prepare-wrangler-config.ts +3 -3
- package/src/scripts/spa-shell.test.ts +1 -1
- package/src/scripts/validate-locales.test.ts +1 -1
- package/src/scripts/verify-migrations.test.ts +1 -1
- package/src/scripts/verify-spa-shell.ts +1 -1
- package/src/scripts/wrangler-config/patches.ts +1 -1
- package/src/scripts/wrangler-config/resources.ts +4 -4
- package/src/test/integration-migrations.test.ts +1 -1
- package/src/vite.test.ts +1 -1
- package/src/vitest-aliases.test.ts +53 -0
- package/src/vitest-aliases.ts +127 -0
- package/src/vitest-factories.test.ts +127 -0
- package/src/vitest-integration.ts +118 -0
- package/src/vitest-repo.ts +269 -0
- package/src/vitest-web.ts +110 -28
- 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
|
-
|
|
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), `
|
|
83
|
-
|
|
84
|
-
`
|
|
85
|
-
|
|
86
|
-
`
|
|
87
|
-
|
|
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
|
|
109
|
-
(`test/**/web
|
|
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,10 +34,16 @@ 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
|
|
28
|
-
* appear in all
|
|
29
|
-
*
|
|
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
49
|
/** Directory the rule is scoped to. */
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"eslint-boundaries.d.ts","sourceRoot":"","sources":["../src/eslint-boundaries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAcjD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,QAAQ;IACvB,uCAAuC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,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"}
|
|
@@ -7,10 +7,20 @@
|
|
|
7
7
|
* argues about — are their own module rather than the tail of a 640-line
|
|
8
8
|
* config file.
|
|
9
9
|
*
|
|
10
|
+
* Converged across all nine family repos: `provider-clients` (AWS-AccessBridge,
|
|
11
|
+
* CalDAV-Bridge, Mail-Meow, Mail-Otter), `webdav`/`dav-store` (Durable-DAV,
|
|
12
|
+
* Durable-DAV-Router, Edge-Sonic), `git-protocol`/`git-service` (Edge-Git).
|
|
13
|
+
* `media-tags`/`subsonic` (Edge-Sonic) carry no boundary block in their source
|
|
14
|
+
* repo — they are unconstrained utility leaves — so they have no layer here.
|
|
15
|
+
*
|
|
10
16
|
* The table is data rather than inline blocks so the dynamic-`import()` guard
|
|
11
17
|
* is generated from the same list: a rule that derived its banned set from
|
|
12
18
|
* another rule's configuration would be a second source of truth for the layer
|
|
13
19
|
* table, and that table is what the docs describe.
|
|
20
|
+
*
|
|
21
|
+
* The table is a superset: a repo without a domain package simply never imports
|
|
22
|
+
* it, so its ban never fires. A layer entry for a directory that does not exist
|
|
23
|
+
* in the consumer matches no file and costs nothing.
|
|
14
24
|
*/
|
|
15
25
|
/**
|
|
16
26
|
* The directories the boundary rules cover, in the canonical layout.
|
|
@@ -24,6 +34,11 @@ export const DEFAULT_PROJECT_DIRS = [
|
|
|
24
34
|
'packages/backend-errors',
|
|
25
35
|
'packages/backend-runtime',
|
|
26
36
|
'packages/backend-data',
|
|
37
|
+
'packages/provider-clients',
|
|
38
|
+
'packages/webdav',
|
|
39
|
+
'packages/dav-store',
|
|
40
|
+
'packages/git-protocol',
|
|
41
|
+
'packages/git-service',
|
|
27
42
|
'packages/backend-services',
|
|
28
43
|
'apps/api',
|
|
29
44
|
'apps/background',
|
|
@@ -47,14 +62,65 @@ export function layerBans(scope) {
|
|
|
47
62
|
},
|
|
48
63
|
{
|
|
49
64
|
dir: 'packages/backend-runtime',
|
|
50
|
-
ban: [
|
|
65
|
+
ban: [
|
|
66
|
+
at('backend-data'),
|
|
67
|
+
at('provider-clients'),
|
|
68
|
+
at('webdav'),
|
|
69
|
+
at('dav-store'),
|
|
70
|
+
at('git-protocol'),
|
|
71
|
+
at('git-service'),
|
|
72
|
+
at('backend-services'),
|
|
73
|
+
at('api'),
|
|
74
|
+
at('background'),
|
|
75
|
+
],
|
|
51
76
|
message: 'backend-runtime must not import from a higher layer',
|
|
52
77
|
},
|
|
53
78
|
{
|
|
54
79
|
dir: 'packages/backend-data',
|
|
55
|
-
ban: [
|
|
80
|
+
ban: [
|
|
81
|
+
at('backend-runtime'),
|
|
82
|
+
at('provider-clients'),
|
|
83
|
+
at('webdav'),
|
|
84
|
+
at('dav-store'),
|
|
85
|
+
at('git-protocol'),
|
|
86
|
+
at('git-service'),
|
|
87
|
+
at('backend-services'),
|
|
88
|
+
at('api'),
|
|
89
|
+
at('background'),
|
|
90
|
+
],
|
|
56
91
|
message: 'backend-data must not import from a higher layer',
|
|
57
92
|
},
|
|
93
|
+
// Domain protocol layers (layer 2, beside backend-data): each bans the DAO
|
|
94
|
+
// layer, the runtime, its store counterpart where it has one, the service
|
|
95
|
+
// layer and the apps. Sources: provider-clients (AWS-AccessBridge,
|
|
96
|
+
// Mail-Meow), webdav (Durable-DAV, Edge-Sonic), git-protocol (Edge-Git).
|
|
97
|
+
{
|
|
98
|
+
dir: 'packages/provider-clients',
|
|
99
|
+
ban: [at('backend-data'), at('backend-runtime'), at('backend-services'), at('api'), at('background')],
|
|
100
|
+
message: 'provider-clients must not import DAOs from backend-data',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
dir: 'packages/webdav',
|
|
104
|
+
ban: [at('backend-data'), at('backend-runtime'), at('dav-store'), at('backend-services'), at('api'), at('background')],
|
|
105
|
+
message: 'webdav must not import DAOs from backend-data',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
dir: 'packages/git-protocol',
|
|
109
|
+
ban: [at('backend-data'), at('backend-runtime'), at('git-service'), at('backend-services'), at('api'), at('background')],
|
|
110
|
+
message: 'git-protocol must not import DAOs from backend-data',
|
|
111
|
+
},
|
|
112
|
+
// Domain store layers (layer 2-3): only layers 0-2, never services or apps.
|
|
113
|
+
// Sources: dav-store (Durable-DAV), git-service (Edge-Git).
|
|
114
|
+
{
|
|
115
|
+
dir: 'packages/dav-store',
|
|
116
|
+
ban: [at('backend-services'), at('api'), at('background')],
|
|
117
|
+
message: 'dav-store must not import from backend-services (higher layer)',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
dir: 'packages/git-service',
|
|
121
|
+
ban: [at('backend-services'), at('api'), at('background')],
|
|
122
|
+
message: 'git-service must not import from backend-services (higher layer)',
|
|
123
|
+
},
|
|
58
124
|
{
|
|
59
125
|
dir: 'packages/backend-services',
|
|
60
126
|
ban: [at('api'), at('background')],
|
|
@@ -64,7 +130,27 @@ export function layerBans(scope) {
|
|
|
64
130
|
dir: 'apps/api',
|
|
65
131
|
ban: [at('backend-data/dao'), at('backend-data')],
|
|
66
132
|
allowTypeImports: true,
|
|
67
|
-
message: 'apps/api must not import DAOs or backend-data values directly; use backend-services instead',
|
|
133
|
+
message: 'apps/api must not import DAOs or backend-data values directly; use backend-services instead (type-only imports are allowed)',
|
|
134
|
+
},
|
|
135
|
+
// Direct-client bans: one entry per client package so each message names
|
|
136
|
+
// the correct alternative. A repo holds at most one of these packages, so
|
|
137
|
+
// the other two never fire. Sources: provider-clients (AWS-AccessBridge,
|
|
138
|
+
// Mail-Meow, Mail-Otter, CalDAV-Bridge), dav-store (Durable-DAV),
|
|
139
|
+
// git-service (Edge-Git).
|
|
140
|
+
{
|
|
141
|
+
dir: 'apps/api',
|
|
142
|
+
ban: [at('provider-clients')],
|
|
143
|
+
message: `apps/api must not import provider-clients directly; use ${scope}/backend-services instead`,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
dir: 'apps/api',
|
|
147
|
+
ban: [at('dav-store')],
|
|
148
|
+
message: `apps/api must not import dav-store directly; use ${scope}/webdav + DO RPC via ${scope}/background instead`,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
dir: 'apps/api',
|
|
152
|
+
ban: [at('git-service')],
|
|
153
|
+
message: `apps/api must not import git-service directly; use ${scope}/git-protocol + DO RPC via ${scope}/background instead`,
|
|
68
154
|
},
|
|
69
155
|
{
|
|
70
156
|
dir: 'apps/background',
|
|
@@ -1 +1 @@
|
|
|
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,cAAc,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC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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
|
+
{"version":3,"file":"eslint-boundaries.js","sourceRoot":"","sources":["../src/eslint-boundaries.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,iBAAiB;IACjB,yBAAyB;IACzB,0BAA0B;IAC1B,uBAAuB;IACvB,2BAA2B;IAC3B,iBAAiB;IACjB,oBAAoB;IACpB,uBAAuB;IACvB,sBAAsB;IACtB,2BAA2B;IAC3B,UAAU;IACV,iBAAiB;IACjB,UAAU;CACX,CAAC;AA2BF;;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,EAA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AC;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 * 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 /** 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: [\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('/', '\\\\/')}/]`,\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"]}
|
package/dist/eslint.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The converged ESLint flat config for a monorepo in the Rexezuge family.
|
|
3
3
|
*
|
|
4
|
-
* Provenance: the base is Durable-DAV's `eslint.config.mjs` (
|
|
4
|
+
* Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most
|
|
5
5
|
* elaborate of the nine repos, with the layered `no-restricted-imports` boundary
|
|
6
|
-
* rules). Merged in from the
|
|
6
|
+
* rules). Merged in from the stacks that share the same plugin set:
|
|
7
7
|
*
|
|
8
8
|
* - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,
|
|
9
9
|
* with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* `allowTypeImports` where the source repos do not. It is also the source for
|
|
15
15
|
* the anchored skip patterns and the symlink-safe walk that came out of its own
|
|
16
16
|
* backlog.
|
|
17
|
+
* - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —
|
|
18
|
+
* the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`
|
|
19
|
+
* layers and the per-client `apps/api` alternatives in the boundary table.
|
|
17
20
|
*
|
|
18
21
|
* Canonical decisions, and why each one:
|
|
19
22
|
*
|
|
@@ -21,9 +24,11 @@
|
|
|
21
24
|
* `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see
|
|
22
25
|
* is a gate that has never run. Formatting drift is therefore a hard failure.
|
|
23
26
|
* 2. **The layered boundary rules are parameterized by `scope`.** Every source
|
|
24
|
-
* repo wrote the same
|
|
27
|
+
* repo wrote the same blocks with a different npm scope hardcoded; the
|
|
25
28
|
* factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.
|
|
26
|
-
* The table itself lives in {@link ./eslint-boundaries}
|
|
29
|
+
* The table itself lives in {@link ./eslint-boundaries.ts} and covers the
|
|
30
|
+
* family superset — a repo without a domain package never triggers its ban,
|
|
31
|
+
* so no repo needs `extraLayers` for a known package.
|
|
27
32
|
* 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;
|
|
28
33
|
* Edge-Sonic does not, and records why: ~200 KB of test code had accumulated
|
|
29
34
|
* violations that nothing reported.
|
|
@@ -39,13 +44,13 @@
|
|
|
39
44
|
* zero-dependency, and the plugin belongs to the app that has JSX. A consumer
|
|
40
45
|
* appends it — the README shows the four lines.
|
|
41
46
|
*
|
|
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
|
|
47
|
+
* The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in
|
|
48
|
+
* {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a
|
|
44
49
|
* boundary the canonical table does not name passes `extraLayers` — see
|
|
45
50
|
* {@link RepoLintConfigOptions}.
|
|
46
51
|
*/
|
|
47
52
|
import type { FlatConfig } from 'typescript-eslint';
|
|
48
|
-
import type { LayerBan } from './eslint-boundaries';
|
|
53
|
+
import type { LayerBan } from './eslint-boundaries.ts';
|
|
49
54
|
/**
|
|
50
55
|
* What `defineRepoLintConfig` accepts.
|
|
51
56
|
*/
|
package/dist/eslint.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AASH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC5C;AAsCD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,UAAU,CAAC,WAAW,CAkH3F"}
|
package/dist/eslint.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The converged ESLint flat config for a monorepo in the Rexezuge family.
|
|
3
3
|
*
|
|
4
|
-
* Provenance: the base is Durable-DAV's `eslint.config.mjs` (
|
|
4
|
+
* Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most
|
|
5
5
|
* elaborate of the nine repos, with the layered `no-restricted-imports` boundary
|
|
6
|
-
* rules). Merged in from the
|
|
6
|
+
* rules). Merged in from the stacks that share the same plugin set:
|
|
7
7
|
*
|
|
8
8
|
* - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,
|
|
9
9
|
* with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* `allowTypeImports` where the source repos do not. It is also the source for
|
|
15
15
|
* the anchored skip patterns and the symlink-safe walk that came out of its own
|
|
16
16
|
* backlog.
|
|
17
|
+
* - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —
|
|
18
|
+
* the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`
|
|
19
|
+
* layers and the per-client `apps/api` alternatives in the boundary table.
|
|
17
20
|
*
|
|
18
21
|
* Canonical decisions, and why each one:
|
|
19
22
|
*
|
|
@@ -21,9 +24,11 @@
|
|
|
21
24
|
* `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see
|
|
22
25
|
* is a gate that has never run. Formatting drift is therefore a hard failure.
|
|
23
26
|
* 2. **The layered boundary rules are parameterized by `scope`.** Every source
|
|
24
|
-
* repo wrote the same
|
|
27
|
+
* repo wrote the same blocks with a different npm scope hardcoded; the
|
|
25
28
|
* factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.
|
|
26
|
-
* The table itself lives in {@link ./eslint-boundaries}
|
|
29
|
+
* The table itself lives in {@link ./eslint-boundaries.ts} and covers the
|
|
30
|
+
* family superset — a repo without a domain package never triggers its ban,
|
|
31
|
+
* so no repo needs `extraLayers` for a known package.
|
|
27
32
|
* 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;
|
|
28
33
|
* Edge-Sonic does not, and records why: ~200 KB of test code had accumulated
|
|
29
34
|
* violations that nothing reported.
|
|
@@ -39,8 +44,8 @@
|
|
|
39
44
|
* zero-dependency, and the plugin belongs to the app that has JSX. A consumer
|
|
40
45
|
* appends it — the README shows the four lines.
|
|
41
46
|
*
|
|
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
|
|
47
|
+
* The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in
|
|
48
|
+
* {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a
|
|
44
49
|
* boundary the canonical table does not name passes `extraLayers` — see
|
|
45
50
|
* {@link RepoLintConfigOptions}.
|
|
46
51
|
*/
|
|
@@ -51,8 +56,8 @@ import { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';
|
|
|
51
56
|
import pluginRegexp from 'eslint-plugin-regexp';
|
|
52
57
|
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
53
58
|
import prettier from 'eslint-plugin-prettier';
|
|
54
|
-
import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from
|
|
55
|
-
import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from
|
|
59
|
+
import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from "./eslint-boundaries.js";
|
|
60
|
+
import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from "./eslint-rules.js";
|
|
56
61
|
/**
|
|
57
62
|
* Bridge a third-party preset into `tseslint.config()`.
|
|
58
63
|
*
|
package/dist/eslint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;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C1E,+CAA+C;IAC/C,QAAQ,CAAC,oBAAoB,CAAC,EAC9B;QACE,OAAO,EAAE,EAAE,QAAQ,EAAE;QACrB,KAAK,EAAE;YACL,mBAAmB,EAAE,OAAO;SAC7B;KACF;IAED,+DAA+D;IAC/D,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAC1B,GAAG,wBAAwB,CAAC,IAAI,CAAC;IAEjC,oEAAoE;IACpE,EAAE;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,+CAA+C;IAC/C;QACE,KAAK,EAAE,CAAC,+CAA+C,CAAC;QACxD,eAAe,EAAE;YACf,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE;SACjD;KACF;IAED,qBAAqB;IACrB,EAAE;IACF,0EAA0E;IAC1E,sDAAsD;IACtD;QACE,KAAK,EAAE,CAAC,4BAA4B,EAAE,4BAA4B,EAAE,4BAA4B,CAAC;QACjG,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;KAC3B,CACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The converged ESLint flat config for a monorepo in the Rexezuge family.\n *\n * Provenance: the base is Durable-DAV's `eslint.config.mjs` (380+ lines, the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the other three stacks that share the same plugin set:\n *\n * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,\n * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`\n * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary\n * guard and its `apps/web` layer block.\n * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.\n * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses\n * `allowTypeImports` where the source repos do not. It is also the source for\n * the anchored skip patterns and the symlink-safe walk that came out of its own\n * backlog.\n *\n * Canonical decisions, and why each one:\n *\n * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at\n * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see\n * is a gate that has never run. Formatting drift is therefore a hard failure.\n * 2. **The layered boundary rules are parameterized by `scope`.** Every source\n * repo wrote the same seven blocks with a different npm scope hardcoded; the\n * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.\n * The table itself lives in {@link ./eslint-boundaries}.\n * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;\n * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated\n * violations that nothing reported.\n * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`\n * package. Edge-Sonic is the only source with that block; the others had none,\n * which is how their layer table's \"may import: the browser\" was a convention\n * rather than a gate. A backend package imported by the SPA compiles and then\n * fails at bundle time, with the error pointing at the bundler.\n * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;\n * `apps/web` needs browser globals as well, and the vitest config for the SPA\n * runs under jsdom, so the lint environment matches the test environment.\n * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays\n * zero-dependency, and the plugin belongs to the app that has JSX. A consumer\n * appends it — the README shows the four lines.\n *\n * The rule bodies live in {@link ./eslint-rules} and the boundary table in\n * {@link ./eslint-boundaries}; this file is the assembly. A repo that needs a\n * boundary the canonical table does not name passes `extraLayers` — see\n * {@link RepoLintConfigOptions}.\n */\n\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\nimport unicorn from 'eslint-plugin-unicorn';\nimport { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';\nimport pluginRegexp from 'eslint-plugin-regexp';\nimport eslintConfigPrettier from 'eslint-config-prettier';\nimport prettier from 'eslint-plugin-prettier';\nimport type { FlatConfig } from 'typescript-eslint';\nimport { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries';\nimport type { LayerBan } from './eslint-boundaries';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules';\n\n/**\n * What `defineRepoLintConfig` accepts.\n */\nexport interface RepoLintConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`\n * pattern in the boundary rules is derived from it, so the same factory serves\n * all nine repos.\n */\n readonly scope: string;\n /**\n * The workspace directories the layered boundary rules are scoped to, as repo-\n * relative globs. Defaults to the canonical layout the nine repos share.\n */\n readonly projectDirs?: readonly string[];\n /**\n * Extra ignore globs, merged with the canonical set.\n */\n readonly extraIgnores?: readonly string[];\n /**\n * Where `projectService` resolves the tsconfig from. Defaults to the directory\n * ESLint is invoked in, which is the repo root in every CI job.\n */\n readonly tsconfigRootDir?: string;\n /**\n * Extra boundary layers, appended to the canonical table.\n *\n * The escape valve for a repo whose layout has a boundary the canonical table\n * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule (\"route\n * classes must not import DAOs directly\") and its `aws4fetch` ban are the shape.\n * Same {@link LayerBan} form, so `extraLayers` flows through the\n * `no-restricted-imports` and the `no-restricted-syntax` guard alike.\n */\n readonly extraLayers?: readonly LayerBan[];\n}\n\n/**\n * One argument to `tseslint.config()`.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * A plugin preset or config object as the source repos pass it.\n */\ntype MaybeConfig = FlatConfig.Config | readonly FlatConfig.Config[];\n\n/**\n * Bridge a third-party preset into `tseslint.config()`.\n *\n * `sonarjs`' `recommended` preset is typed as a union that includes the legacy\n * config shape, which `tseslint.config()` does not accept — but ESLint accepts it\n * at runtime, which is the only thing that matters here. One checked assertion,\n * rather than forking the plugin's own types.\n */\nfunction asConfig(config: MaybeConfig): ConfigInput {\n return config as ConfigInput;\n}\n\n/**\n * Bridge a rule block onto `tseslint.config()`'s `rules` field.\n *\n * The blocks in `eslint-rules.ts` are written as ESLint expects them —\n * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a\n * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`\n * union is narrower than the data shape, and widening every entry to that union\n * would buy nothing; one assertion here, with the reason, is the cheaper and\n * more honest of the two.\n */\nfunction asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {\n return block as FlatConfig.Config['rules'];\n}\n\n/**\n * Build the repo's flat config.\n *\n * Consumed from the repo root as three lines:\n *\n * ```js\n * // eslint.config.mjs\n * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';\n * export default defineRepoLintConfig({ scope: '@myapp' });\n * ```\n */\nexport function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig.ConfigArray {\n const { scope } = options;\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));\n const extra = options.extraLayers ?? [];\n const bans = [...canonical, ...extra];\n\n return tseslint.config(\n {\n ignores: [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'scripts/**',\n 'worker-configuration.d.ts',\n 'local/**',\n 'app/dist/**',\n 'apps/web/dist/**',\n 'apps/*/dist/**',\n 'src/generated/**',\n 'apps/api/src/generated/**',\n 'coverage/**',\n 'coverage-integration/**',\n 'coverage-web/**',\n 'node_modules/**',\n ...(options.extraIgnores ?? []),\n ],\n },\n\n // Base: globals for all JS/TS source files. Node is the floor because the\n // scripts and the workers both run on it; the web block below adds browser\n // globals rather than replacing them, so a shared file that touches both\n // (there are several in `shared/`) still lints.\n {\n files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],\n languageOptions: {\n globals: globals.node,\n },\n },\n\n // Type-aware TS rules, scoped to TS files only.\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n extends: tseslint.configs.recommendedTypeChecked,\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),\n },\n },\n },\n\n // --- typescript-eslint overrides (identical in all four source stacks) ---\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n rules: asRules(TYPESCRIPT_RULES),\n },\n\n // --- Unicorn: modern JS/TS quality rules ---\n asConfig(unicorn.configs['flat/recommended']),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS: code smell and bug detection ---\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(SONARJS_RULES),\n },\n\n // --- Regexp: static analysis for regular expressions ---\n asConfig(pluginRegexp.configs['flat/recommended']),\n\n // --- Prettier: formatting drift is a hard error ---\n //\n // Mail-Meow's decision, adopted repo-wide because the alternative is\n // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the\n // four source repos, and `--quiet` discards every warning, so a\n // `prettier/prettier` *warning* is a silent no-op. 242 files were in that\n // state in Edge-Sonic: the gate had never run.\n asConfig(eslintConfigPrettier),\n {\n plugins: { prettier },\n rules: {\n 'prettier/prettier': 'error',\n },\n },\n\n // --- Import direction guardrails (parameterized by scope) ---\n ...restrictedImports(bans),\n ...restrictedDynamicImports(bans),\n\n // --- Web: browser globals, matching the jsdom test environment ---\n //\n // The sources linted `apps/web` under `globals.node` only, so `window`,\n // `document` and `localStorage` read as undefined globals. The vitest web\n // config runs those suites under jsdom; the lint environment should agree\n // with the environment the code is executed in, or the rule is reporting\n // something untrue about how the file behaves.\n {\n files: ['apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}'],\n languageOptions: {\n globals: { ...globals.node, ...globals.browser },\n },\n },\n\n // --- Test suite ---\n //\n // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES\n // for the override block and the reasoning behind it.\n {\n files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],\n rules: asRules(TEST_RULES),\n },\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,QAA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,EAAE;QACrB,KAAK,EAAE;YACL,mBAAmB,EAAE,OAAO;SAC7B;KACF;IAED,+DAA+D;IAC/D,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAC1B,GAAG,wBAAwB,CAAC,IAAI,CAAC;IAEjC,oEAAoE;IACpE,EAAE;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,+CAA+C;IAC/C;QACE,KAAK,EAAE,CAAC,+CAA+C,CAAC;QACxD,eAAe,EAAE;YACf,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE;SACjD;KACF;IAED,qBAAqB;IACrB,EAAE;IACF,0EAA0E;IAC1E,sDAAsD;IACtD;QACE,KAAK,EAAE,CAAC,4BAA4B,EAAE,4BAA4B,EAAE,4BAA4B,CAAC;QACjG,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;KAC3B,CACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The converged ESLint flat config for a monorepo in the Rexezuge family.\n *\n * Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the stacks that share the same plugin set:\n *\n * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,\n * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`\n * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary\n * guard and its `apps/web` layer block.\n * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.\n * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses\n * `allowTypeImports` where the source repos do not. It is also the source for\n * the anchored skip patterns and the symlink-safe walk that came out of its own\n * backlog.\n * - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —\n * the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`\n * layers and the per-client `apps/api` alternatives in the boundary table.\n *\n * Canonical decisions, and why each one:\n *\n * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at\n * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see\n * is a gate that has never run. Formatting drift is therefore a hard failure.\n * 2. **The layered boundary rules are parameterized by `scope`.** Every source\n * repo wrote the same blocks with a different npm scope hardcoded; the\n * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.\n * The table itself lives in {@link ./eslint-boundaries.ts} and covers the\n * family superset — a repo without a domain package never triggers its ban,\n * so no repo needs `extraLayers` for a known package.\n * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;\n * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated\n * violations that nothing reported.\n * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`\n * package. Edge-Sonic is the only source with that block; the others had none,\n * which is how their layer table's \"may import: the browser\" was a convention\n * rather than a gate. A backend package imported by the SPA compiles and then\n * fails at bundle time, with the error pointing at the bundler.\n * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;\n * `apps/web` needs browser globals as well, and the vitest config for the SPA\n * runs under jsdom, so the lint environment matches the test environment.\n * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays\n * zero-dependency, and the plugin belongs to the app that has JSX. A consumer\n * appends it — the README shows the four lines.\n *\n * The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in\n * {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a\n * boundary the canonical table does not name passes `extraLayers` — see\n * {@link RepoLintConfigOptions}.\n */\n\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\nimport unicorn from 'eslint-plugin-unicorn';\nimport { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';\nimport pluginRegexp from 'eslint-plugin-regexp';\nimport eslintConfigPrettier from 'eslint-config-prettier';\nimport prettier from 'eslint-plugin-prettier';\nimport type { FlatConfig } from 'typescript-eslint';\nimport { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries.ts';\nimport type { LayerBan } from './eslint-boundaries.ts';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules.ts';\n\n/**\n * What `defineRepoLintConfig` accepts.\n */\nexport interface RepoLintConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`\n * pattern in the boundary rules is derived from it, so the same factory serves\n * all nine repos.\n */\n readonly scope: string;\n /**\n * The workspace directories the layered boundary rules are scoped to, as repo-\n * relative globs. Defaults to the canonical layout the nine repos share.\n */\n readonly projectDirs?: readonly string[];\n /**\n * Extra ignore globs, merged with the canonical set.\n */\n readonly extraIgnores?: readonly string[];\n /**\n * Where `projectService` resolves the tsconfig from. Defaults to the directory\n * ESLint is invoked in, which is the repo root in every CI job.\n */\n readonly tsconfigRootDir?: string;\n /**\n * Extra boundary layers, appended to the canonical table.\n *\n * The escape valve for a repo whose layout has a boundary the canonical table\n * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule (\"route\n * classes must not import DAOs directly\") and its `aws4fetch` ban are the shape.\n * Same {@link LayerBan} form, so `extraLayers` flows through the\n * `no-restricted-imports` and the `no-restricted-syntax` guard alike.\n */\n readonly extraLayers?: readonly LayerBan[];\n}\n\n/**\n * One argument to `tseslint.config()`.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * A plugin preset or config object as the source repos pass it.\n */\ntype MaybeConfig = FlatConfig.Config | readonly FlatConfig.Config[];\n\n/**\n * Bridge a third-party preset into `tseslint.config()`.\n *\n * `sonarjs`' `recommended` preset is typed as a union that includes the legacy\n * config shape, which `tseslint.config()` does not accept — but ESLint accepts it\n * at runtime, which is the only thing that matters here. One checked assertion,\n * rather than forking the plugin's own types.\n */\nfunction asConfig(config: MaybeConfig): ConfigInput {\n return config as ConfigInput;\n}\n\n/**\n * Bridge a rule block onto `tseslint.config()`'s `rules` field.\n *\n * The blocks in `eslint-rules.ts` are written as ESLint expects them —\n * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a\n * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`\n * union is narrower than the data shape, and widening every entry to that union\n * would buy nothing; one assertion here, with the reason, is the cheaper and\n * more honest of the two.\n */\nfunction asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {\n return block as FlatConfig.Config['rules'];\n}\n\n/**\n * Build the repo's flat config.\n *\n * Consumed from the repo root as three lines:\n *\n * ```js\n * // eslint.config.mjs\n * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';\n * export default defineRepoLintConfig({ scope: '@myapp' });\n * ```\n */\nexport function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig.ConfigArray {\n const { scope } = options;\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));\n const extra = options.extraLayers ?? [];\n const bans = [...canonical, ...extra];\n\n return tseslint.config(\n {\n ignores: [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'scripts/**',\n 'worker-configuration.d.ts',\n 'local/**',\n 'app/dist/**',\n 'apps/web/dist/**',\n 'apps/*/dist/**',\n 'src/generated/**',\n 'apps/api/src/generated/**',\n 'coverage/**',\n 'coverage-integration/**',\n 'coverage-web/**',\n 'node_modules/**',\n ...(options.extraIgnores ?? []),\n ],\n },\n\n // Base: globals for all JS/TS source files. Node is the floor because the\n // scripts and the workers both run on it; the web block below adds browser\n // globals rather than replacing them, so a shared file that touches both\n // (there are several in `shared/`) still lints.\n {\n files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],\n languageOptions: {\n globals: globals.node,\n },\n },\n\n // Type-aware TS rules, scoped to TS files only.\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n extends: tseslint.configs.recommendedTypeChecked,\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),\n },\n },\n },\n\n // --- typescript-eslint overrides (identical in all four source stacks) ---\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n rules: asRules(TYPESCRIPT_RULES),\n },\n\n // --- Unicorn: modern JS/TS quality rules ---\n asConfig(unicorn.configs['flat/recommended']),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS: code smell and bug detection ---\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(SONARJS_RULES),\n },\n\n // --- Regexp: static analysis for regular expressions ---\n asConfig(pluginRegexp.configs['flat/recommended']),\n\n // --- Prettier: formatting drift is a hard error ---\n //\n // Mail-Meow's decision, adopted repo-wide because the alternative is\n // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the\n // four source repos, and `--quiet` discards every warning, so a\n // `prettier/prettier` *warning* is a silent no-op. 242 files were in that\n // state in Edge-Sonic: the gate had never run.\n asConfig(eslintConfigPrettier),\n {\n plugins: { prettier },\n rules: {\n 'prettier/prettier': 'error',\n },\n },\n\n // --- Import direction guardrails (parameterized by scope) ---\n ...restrictedImports(bans),\n ...restrictedDynamicImports(bans),\n\n // --- Web: browser globals, matching the jsdom test environment ---\n //\n // The sources linted `apps/web` under `globals.node` only, so `window`,\n // `document` and `localStorage` read as undefined globals. The vitest web\n // config runs those suites under jsdom; the lint environment should agree\n // with the environment the code is executed in, or the rule is reporting\n // something untrue about how the file behaves.\n {\n files: ['apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}'],\n languageOptions: {\n globals: { ...globals.node, ...globals.browser },\n },\n },\n\n // --- Test suite ---\n //\n // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES\n // for the override block and the reasoning behind it.\n {\n files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],\n rules: asRules(TEST_RULES),\n },\n );\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,18 +14,24 @@
|
|
|
14
14
|
* and is only ever resolved in the consumer's repo, where the kit is installed
|
|
15
15
|
* alongside `@rexezuge/d1`.
|
|
16
16
|
*/
|
|
17
|
-
export { defineRepoLintConfig } from './eslint';
|
|
18
|
-
export type { RepoLintConfigOptions } from './eslint';
|
|
19
|
-
export { defineUnitVitestConfig } from './vitest';
|
|
20
|
-
export type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest';
|
|
21
|
-
export { defineWebVitestConfig } from './vitest-web';
|
|
22
|
-
export type { WebVitestConfigOptions } from './vitest-web';
|
|
23
|
-
export {
|
|
24
|
-
export type {
|
|
25
|
-
export {
|
|
26
|
-
export type {
|
|
27
|
-
export {
|
|
28
|
-
export type {
|
|
29
|
-
export {
|
|
30
|
-
export type {
|
|
17
|
+
export { defineRepoLintConfig } from './eslint.ts';
|
|
18
|
+
export type { RepoLintConfigOptions } from './eslint.ts';
|
|
19
|
+
export { defineUnitVitestConfig } from './vitest.ts';
|
|
20
|
+
export type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest.ts';
|
|
21
|
+
export { defineWebVitestConfig } from './vitest-web.ts';
|
|
22
|
+
export type { WebVitestConfigOptions } from './vitest-web.ts';
|
|
23
|
+
export { defineRepoVitestConfig } from './vitest-repo.ts';
|
|
24
|
+
export type { RepoBackendOptions, RepoVitestConfigOptions, RepoWebOptions } from './vitest-repo.ts';
|
|
25
|
+
export { defineIntegrationVitestConfig } from './vitest-integration.ts';
|
|
26
|
+
export type { IntegrationVitestConfigOptions } from './vitest-integration.ts';
|
|
27
|
+
export { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';
|
|
28
|
+
export type { VitestAlias as WorkspaceAlias, WorkspaceAliasesOptions } from './vitest-aliases.ts';
|
|
29
|
+
export { defineWebViteConfig, spaShellEmbedPlugin } from './vite.ts';
|
|
30
|
+
export type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite.ts';
|
|
31
|
+
export { createPagesProxy } from './functions/pages-proxy.ts';
|
|
32
|
+
export type { Fetcher, PagesFunction, PagesFunctionContext, PagesProxyEnv, PagesProxyOptions } from './functions/pages-proxy.ts';
|
|
33
|
+
export { DurableObject, RpcTarget, WorkflowEntrypoint } from './test/mocks/cloudflare-workers.ts';
|
|
34
|
+
export type { DurableObjectState, ExecutionContext } from './test/mocks/cloudflare-workers.ts';
|
|
35
|
+
export { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations.ts';
|
|
36
|
+
export type { D1DatabaseLike, D1PreparedStatementLike, MigrationFile, MigrationHelper, MigrationHelperOptions, MigrationRange, } from './test/integration-migrations.ts';
|
|
31
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACxE,YAAY,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9H,YAAY,EAAE,WAAW,IAAI,cAAc,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAOjI,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAClG,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE/F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACvG,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,cAAc,GACf,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,15 +14,18 @@
|
|
|
14
14
|
* and is only ever resolved in the consumer's repo, where the kit is installed
|
|
15
15
|
* alongside `@rexezuge/d1`.
|
|
16
16
|
*/
|
|
17
|
-
export { defineRepoLintConfig } from
|
|
18
|
-
export { defineUnitVitestConfig } from
|
|
19
|
-
export { defineWebVitestConfig } from
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
17
|
+
export { defineRepoLintConfig } from "./eslint.js";
|
|
18
|
+
export { defineUnitVitestConfig } from "./vitest.js";
|
|
19
|
+
export { defineWebVitestConfig } from "./vitest-web.js";
|
|
20
|
+
export { defineRepoVitestConfig } from "./vitest-repo.js";
|
|
21
|
+
export { defineIntegrationVitestConfig } from "./vitest-integration.js";
|
|
22
|
+
export { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from "./vitest-aliases.js";
|
|
23
|
+
export { defineWebViteConfig, spaShellEmbedPlugin } from "./vite.js";
|
|
24
|
+
export { createPagesProxy } from "./functions/pages-proxy.js";
|
|
22
25
|
// --- Test helpers ---------------------------------------------------------
|
|
23
26
|
//
|
|
24
27
|
// Aliased in a Vitest config, not imported by application code, so the mocks stay
|
|
25
28
|
// where the suites can reach them.
|
|
26
|
-
export { DurableObject, RpcTarget, WorkflowEntrypoint } from
|
|
27
|
-
export { createMigrationHelper, readMigrationFiles, splitSql } from
|
|
29
|
+
export { DurableObject, RpcTarget, WorkflowEntrypoint } from "./test/mocks/cloudflare-workers.js";
|
|
30
|
+
export { createMigrationHelper, readMigrationFiles, splitSql } from "./test/integration-migrations.js";
|
|
28
31
|
//# sourceMappingURL=index.js.map
|