@rexezuge/tooling 1.3.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.
- package/dist/eslint-boundaries.d.ts +12 -4
- package/dist/eslint-boundaries.d.ts.map +1 -1
- package/dist/eslint-boundaries.js +1 -224
- package/dist/eslint-boundaries.js.map +7 -1
- package/dist/eslint-rules.js +1 -273
- package/dist/eslint-rules.js.map +7 -1
- package/dist/eslint.js +1 -194
- package/dist/eslint.js.map +7 -1
- package/dist/functions/pages-proxy.d.ts.map +1 -1
- package/dist/functions/pages-proxy.js +1 -131
- package/dist/functions/pages-proxy.js.map +7 -1
- package/dist/index.js +1 -31
- package/dist/index.js.map +7 -1
- package/dist/scripts/backup/d1-target.d.ts +15 -5
- package/dist/scripts/backup/d1-target.d.ts.map +1 -1
- package/dist/scripts/backup/d1-target.js +1 -31
- package/dist/scripts/backup/d1-target.js.map +7 -1
- package/dist/scripts/backup/destination-config.d.ts +24 -8
- package/dist/scripts/backup/destination-config.d.ts.map +1 -1
- package/dist/scripts/backup/destination-config.js +1 -57
- package/dist/scripts/backup/destination-config.js.map +7 -1
- package/dist/scripts/backup/encrypt-backup.js +2 -97
- package/dist/scripts/backup/encrypt-backup.js.map +7 -1
- package/dist/scripts/backup/naming.d.ts +3 -1
- package/dist/scripts/backup/naming.d.ts.map +1 -1
- package/dist/scripts/backup/naming.js +1 -58
- package/dist/scripts/backup/naming.js.map +7 -1
- package/dist/scripts/check-god-files.d.ts +40 -14
- package/dist/scripts/check-god-files.d.ts.map +1 -1
- package/dist/scripts/check-god-files.js +2 -271
- package/dist/scripts/check-god-files.js.map +7 -1
- package/dist/scripts/ensure-spa-shell-stub.js +1 -29
- package/dist/scripts/ensure-spa-shell-stub.js.map +7 -1
- package/dist/scripts/init-secrets.d.ts +0 -16
- package/dist/scripts/init-secrets.d.ts.map +1 -1
- package/dist/scripts/init-secrets.js +2 -239
- package/dist/scripts/init-secrets.js.map +7 -1
- package/dist/scripts/lib/cli-args.d.ts.map +1 -1
- package/dist/scripts/lib/cli-args.js +1 -116
- package/dist/scripts/lib/cli-args.js.map +7 -1
- package/dist/scripts/lib/github-actions.js +3 -38
- package/dist/scripts/lib/github-actions.js.map +7 -1
- package/dist/scripts/lib/wrangler-table.d.ts.map +1 -1
- package/dist/scripts/lib/wrangler-table.js +2 -99
- package/dist/scripts/lib/wrangler-table.js.map +7 -1
- package/dist/scripts/migrations-lock.js +1 -44
- package/dist/scripts/migrations-lock.js.map +7 -1
- package/dist/scripts/prepare-wrangler-config.js +1 -49
- package/dist/scripts/prepare-wrangler-config.js.map +7 -1
- package/dist/scripts/spa-shell.d.ts +12 -4
- package/dist/scripts/spa-shell.d.ts.map +1 -1
- package/dist/scripts/spa-shell.js +3 -160
- package/dist/scripts/spa-shell.js.map +7 -1
- package/dist/scripts/validate-locales.d.ts +13 -5
- package/dist/scripts/validate-locales.d.ts.map +1 -1
- package/dist/scripts/validate-locales.js +4 -350
- package/dist/scripts/validate-locales.js.map +7 -1
- package/dist/scripts/verify-migrations.d.ts +27 -9
- package/dist/scripts/verify-migrations.d.ts.map +1 -1
- package/dist/scripts/verify-migrations.js +2 -312
- package/dist/scripts/verify-migrations.js.map +7 -1
- package/dist/scripts/verify-spa-shell.js +1 -52
- package/dist/scripts/verify-spa-shell.js.map +7 -1
- package/dist/scripts/wrangler-config/cli.js +3 -51
- package/dist/scripts/wrangler-config/cli.js.map +7 -1
- package/dist/scripts/wrangler-config/patches.d.ts +9 -3
- package/dist/scripts/wrangler-config/patches.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/patches.js +4 -141
- package/dist/scripts/wrangler-config/patches.js.map +7 -1
- package/dist/scripts/wrangler-config/resources.d.ts +18 -6
- package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/resources.js +1 -290
- package/dist/scripts/wrangler-config/resources.js.map +7 -1
- package/dist/scripts/wrangler-config/types.d.ts +24 -8
- package/dist/scripts/wrangler-config/types.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/types.js +1 -49
- package/dist/scripts/wrangler-config/types.js.map +7 -1
- package/dist/test/integration-migrations.d.ts +29 -12
- package/dist/test/integration-migrations.d.ts.map +1 -1
- package/dist/test/integration-migrations.js +2 -171
- package/dist/test/integration-migrations.js.map +7 -1
- package/dist/test/mocks/cloudflare-workers.js +1 -90
- package/dist/test/mocks/cloudflare-workers.js.map +7 -1
- package/dist/vite.d.ts +5 -3
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +3 -125
- package/dist/vite.js.map +7 -1
- package/dist/vitest-aliases.d.ts.map +1 -1
- package/dist/vitest-aliases.js +1 -81
- package/dist/vitest-aliases.js.map +7 -1
- package/dist/vitest-integration.js +1 -64
- package/dist/vitest-integration.js.map +7 -1
- package/dist/vitest-repo.js +1 -146
- package/dist/vitest-repo.js.map +7 -1
- package/dist/vitest-web.js +1 -109
- package/dist/vitest-web.js.map +7 -1
- package/dist/vitest.js +1 -133
- package/dist/vitest.js.map +7 -1
- package/package.json +3 -3
- package/src/eslint-boundaries.ts +13 -5
- package/src/eslint.test.ts +18 -8
- package/src/functions/pages-proxy.test.ts +1 -1
- package/src/functions/pages-proxy.ts +4 -2
- package/src/scripts/backup/backup-rules.test.ts +1 -1
- package/src/scripts/backup/d1-target.ts +15 -5
- package/src/scripts/backup/destination-config.ts +27 -9
- package/src/scripts/backup/encrypt-backup.ts +10 -8
- package/src/scripts/backup/naming.ts +3 -1
- package/src/scripts/check-god-files.test.ts +18 -18
- package/src/scripts/check-god-files.ts +60 -31
- package/src/scripts/init-secrets.ts +17 -7
- package/src/scripts/lib/cli-args.ts +6 -3
- package/src/scripts/lib/wrangler-table.ts +5 -3
- package/src/scripts/migrations-lock.ts +1 -1
- package/src/scripts/spa-shell.test.ts +17 -17
- package/src/scripts/spa-shell.ts +26 -14
- package/src/scripts/validate-locales.test.ts +17 -17
- package/src/scripts/validate-locales.ts +43 -25
- package/src/scripts/verify-migrations.test.ts +7 -7
- package/src/scripts/verify-migrations.ts +47 -24
- package/src/scripts/wrangler-config/patches.ts +12 -4
- package/src/scripts/wrangler-config/resources.ts +30 -14
- package/src/scripts/wrangler-config/types.ts +24 -8
- package/src/test/integration-migrations.test.ts +6 -6
- package/src/test/integration-migrations.ts +33 -14
- package/src/vite.test.ts +24 -13
- package/src/vite.ts +5 -5
- package/src/vitest-aliases.ts +1 -3
|
@@ -46,13 +46,21 @@ export declare const DEFAULT_PROJECT_DIRS: readonly string[];
|
|
|
46
46
|
* type-only imports and the direct-client bans do not.
|
|
47
47
|
*/
|
|
48
48
|
export interface LayerBan {
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
Directory the rule is scoped to.
|
|
51
|
+
*/
|
|
50
52
|
readonly dir: string;
|
|
51
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
Package suffixes (relative to `scope`) that may not be imported from here.
|
|
55
|
+
*/
|
|
52
56
|
readonly ban: readonly string[];
|
|
53
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
Message shown when the rule fires.
|
|
59
|
+
*/
|
|
54
60
|
readonly message: string;
|
|
55
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
Type-only imports are allowed, for the DAO boundary in `apps/api`.
|
|
63
|
+
*/
|
|
56
64
|
readonly allowTypeImports?: boolean;
|
|
57
65
|
}
|
|
58
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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAcjD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,QAAQ;IACvB
|
|
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;;MAEE;IACF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;MAEE;IACF,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC;;MAEE;IACF,QAAQ,CAAC,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,224 +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
|
-
* 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
|
-
*
|
|
16
|
-
* The table is data rather than inline blocks so the dynamic-`import()` guard
|
|
17
|
-
* is generated from the same list: a rule that derived its banned set from
|
|
18
|
-
* another rule's configuration would be a second source of truth for the layer
|
|
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.
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* The directories the boundary rules cover, in the canonical layout.
|
|
27
|
-
*
|
|
28
|
-
* Kept here, beside the table it scopes: `defineRepoLintConfig` filters the
|
|
29
|
-
* canonical layers by `projectDirs`, and a reader of the layer table should not
|
|
30
|
-
* have to open the config assembly to learn which directories it covers.
|
|
31
|
-
*/
|
|
32
|
-
export const DEFAULT_PROJECT_DIRS = [
|
|
33
|
-
'packages/shared',
|
|
34
|
-
'packages/backend-errors',
|
|
35
|
-
'packages/backend-runtime',
|
|
36
|
-
'packages/backend-data',
|
|
37
|
-
'packages/provider-clients',
|
|
38
|
-
'packages/webdav',
|
|
39
|
-
'packages/dav-store',
|
|
40
|
-
'packages/git-protocol',
|
|
41
|
-
'packages/git-service',
|
|
42
|
-
'packages/backend-services',
|
|
43
|
-
'apps/api',
|
|
44
|
-
'apps/background',
|
|
45
|
-
'apps/web',
|
|
46
|
-
];
|
|
47
|
-
/**
|
|
48
|
-
* The layer table, parameterized by `scope`.
|
|
49
|
-
*/
|
|
50
|
-
export function layerBans(scope) {
|
|
51
|
-
const at = (name) => `${scope}/${name}`;
|
|
52
|
-
return [
|
|
53
|
-
{
|
|
54
|
-
dir: 'packages/shared',
|
|
55
|
-
ban: [at('*')],
|
|
56
|
-
message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
dir: 'packages/backend-errors',
|
|
60
|
-
ban: [at('*')],
|
|
61
|
-
message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
dir: 'packages/backend-runtime',
|
|
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
|
-
],
|
|
76
|
-
message: 'backend-runtime must not import from a higher layer',
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
dir: 'packages/backend-data',
|
|
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
|
-
],
|
|
91
|
-
message: 'backend-data must not import from a higher layer',
|
|
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
|
-
},
|
|
124
|
-
{
|
|
125
|
-
dir: 'packages/backend-services',
|
|
126
|
-
ban: [at('api'), at('background')],
|
|
127
|
-
message: 'backend-services must not import from apps',
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
dir: 'apps/api',
|
|
131
|
-
ban: [at('backend-data/dao'), at('backend-data')],
|
|
132
|
-
allowTypeImports: true,
|
|
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`,
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
dir: 'apps/background',
|
|
157
|
-
ban: [at('api')],
|
|
158
|
-
message: 'apps/background must not import from apps/api',
|
|
159
|
-
},
|
|
160
|
-
// The browser half, and the only layer that bans the namespace wholesale
|
|
161
|
-
// rather than a list of siblings: a backend package imported by the SPA
|
|
162
|
-
// typechecks and then fails at bundle time, with the error pointing at the
|
|
163
|
-
// bundler rather than at the boundary. Edge-Sonic is the source; the others had
|
|
164
|
-
// no block for it at all, which is how their layer table's "may import: the
|
|
165
|
-
// browser" was a convention instead of a gate.
|
|
166
|
-
{
|
|
167
|
-
dir: 'apps/web',
|
|
168
|
-
ban: [at('*')],
|
|
169
|
-
message: `${at('apps/web')} ships zero backend dependencies — this module is the SPA's own copy`,
|
|
170
|
-
},
|
|
171
|
-
];
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* The `no-restricted-imports` entries for one layer.
|
|
175
|
-
*
|
|
176
|
-
* Written as `group` patterns rather than exact `paths`, so `@myapp/backend-data`
|
|
177
|
-
* and `@myapp/backend-data/dao` are both caught by one entry. `allowTypeImports`
|
|
178
|
-
* is passed through only where the source repos set it, because `apps/api`
|
|
179
|
-
* legitimately types its filters and models against DAO shapes.
|
|
180
|
-
*/
|
|
181
|
-
export function restrictedImports(bans) {
|
|
182
|
-
return bans.map(({ dir, ban, message, allowTypeImports }) => ({
|
|
183
|
-
files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],
|
|
184
|
-
rules: {
|
|
185
|
-
'no-restricted-imports': [
|
|
186
|
-
'error',
|
|
187
|
-
{
|
|
188
|
-
patterns: ban.map((group) => ({
|
|
189
|
-
group: [group, `${group}/*`],
|
|
190
|
-
message,
|
|
191
|
-
...(allowTypeImports === true && { allowTypeImports: true }),
|
|
192
|
-
})),
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
},
|
|
196
|
-
}));
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* The dynamic-`import()` guard, generated from the same table.
|
|
200
|
-
*
|
|
201
|
-
* `no-restricted-imports` reads `ImportDeclaration` nodes only; a dynamic
|
|
202
|
-
* `import()` is an `ImportExpression`, and this ESLint version does not report it
|
|
203
|
-
* under that rule at all. Edge-Sonic verified this rather than assumed it — a
|
|
204
|
-
* static import of a restricted specifier from the same file is an `error`, and
|
|
205
|
-
* the identical specifier reached through `await import(...)` is silent. That
|
|
206
|
-
* hole was load-bearing there: the credential path reached a banned module
|
|
207
|
-
* through it. `no-restricted-syntax` sees `ImportExpression`, so the boundary is
|
|
208
|
-
* stated a second way.
|
|
209
|
-
*/
|
|
210
|
-
export function restrictedDynamicImports(bans) {
|
|
211
|
-
return bans.map(({ dir, ban, message }) => ({
|
|
212
|
-
files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],
|
|
213
|
-
rules: {
|
|
214
|
-
'no-restricted-syntax': [
|
|
215
|
-
'error',
|
|
216
|
-
...ban.map((specifier) => ({
|
|
217
|
-
selector: `ImportExpression[source.type='Literal'][source.value=/^${specifier.replaceAll('/', '\\/')}/]`,
|
|
218
|
-
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}`,
|
|
219
|
-
})),
|
|
220
|
-
],
|
|
221
|
-
},
|
|
222
|
-
}));
|
|
223
|
-
}
|
|
224
|
-
//# 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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,iBAAiB;IACjB,yBAAyB;IACzB,0BAA0B;IAC1B,uBAAuB;IACvB,2BAA2B;IAC3B,iBAAiB;IACjB,oBAAoB;IACpB,u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;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAyB;IACzD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,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 * 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"]}
|
|
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,EAChBA,EAAG,kBAAkB,EACrBA,EAAG,KAAK,EACRA,EAAG,YAAY,GAEjB,QAAS,uDAEX,CACE,IAAK,wBACL,IAAK,CACHA,EAAG,iBAAiB,EACpBA,EAAG,kBAAkB,EACrBA,EAAG,QAAQ,EACXA,EAAG,WAAW,EACdA,EAAG,cAAc,EACjBA,EAAG,aAAa,EAChBA,EAAG,kBAAkB,EACrBA,EAAG,KAAK,EACRA,EAAG,YAAY,GAEjB,QAAS,oDAMX,CACE,IAAK,4BACL,IAAK,CAACA,EAAG,cAAc,EAAGA,EAAG,iBAAiB,EAAGA,EAAG,kBAAkB,EAAGA,EAAG,KAAK,EAAGA,EAAG,YAAY,C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AAOA,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
|
+
}
|
package/dist/eslint-rules.js
CHANGED
|
@@ -1,273 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The rule-override blocks of the repo lint config.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from `eslint.ts` with the boundary rules: each block is a plain
|
|
5
|
-
* rules object with the provenance comment that says *why* it is set to this
|
|
6
|
-
* value, because a per-rule decision with no reason attached is a decision the
|
|
7
|
-
* next reader re-litigates. `eslint.ts` composes these; this file is where a
|
|
8
|
-
* rule's story lives.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* TypeScript rules, identical in all four source stacks.
|
|
12
|
-
*/
|
|
13
|
-
export const TYPESCRIPT_RULES = {
|
|
14
|
-
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
|
15
|
-
// Allow `void expr` for intentional fire-and-forget in Workers.
|
|
16
|
-
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
|
|
17
|
-
// Relax the unsafe-any rules to warn: the external API boundaries (Cloudflare
|
|
18
|
-
// bindings, provider SDKs) are typed `any` upstream, and the alternative is a
|
|
19
|
-
// config that cannot be adopted.
|
|
20
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
21
|
-
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
22
|
-
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
23
|
-
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
24
|
-
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
25
|
-
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
26
|
-
// JSX event handlers and hook callback objects commonly use async functions
|
|
27
|
-
// where void is expected.
|
|
28
|
-
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { attributes: false, properties: false } }],
|
|
29
|
-
// An `async` function with no `await`: every handler and DAO method is
|
|
30
|
-
// `async` by shape so a future `await` does not change its signature.
|
|
31
|
-
'@typescript-eslint/require-await': 'off',
|
|
32
|
-
// `await` on a value the types say is not thenable, where the value is a
|
|
33
|
-
// `PromiseLike` from an interface declared that way.
|
|
34
|
-
'@typescript-eslint/await-thenable': 'off',
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Unicorn and SonarJS rules carried from the source repos, each off for a
|
|
38
|
-
* stated reason.
|
|
39
|
-
*
|
|
40
|
-
* This is the family's "deliberately does not follow" block: every entry is
|
|
41
|
-
* off because complying would make the code worse for what the project is,
|
|
42
|
-
* and each is listed rather than dropped so the decision stays reviewable.
|
|
43
|
-
*/
|
|
44
|
-
export const UNICORN_RULES = {
|
|
45
|
-
// Codebase uses ctx, req, res, env, err, util, db, dao, etc. — too invasive
|
|
46
|
-
// to rename.
|
|
47
|
-
'unicorn/prevent-abbreviations': 'off',
|
|
48
|
-
// D1/DAO layer returns null; disabling this avoids mass rewrites.
|
|
49
|
-
'unicorn/no-null': 'off',
|
|
50
|
-
// Monorepo uses CommonJS-compatible module style in some configs.
|
|
51
|
-
'unicorn/prefer-module': 'off',
|
|
52
|
-
// Top-level await not available in all Workers entry points.
|
|
53
|
-
'unicorn/prefer-top-level-await': 'off',
|
|
54
|
-
// Error subclassing via `new MyError()` is intentional in backend-errors.
|
|
55
|
-
'unicorn/custom-error-definition': 'off',
|
|
56
|
-
// Allow process.exit in build/script files.
|
|
57
|
-
'unicorn/no-process-exit': 'off',
|
|
58
|
-
// Array reduce is used intentionally in analytics/data transformation.
|
|
59
|
-
'unicorn/no-array-reduce': 'off',
|
|
60
|
-
// Allow Number() — parseInt/parseFloat are used in some cases intentionally.
|
|
61
|
-
'unicorn/prefer-number-properties': ['error', { checkInfinity: false }],
|
|
62
|
-
// Allow nested ternaries in JSX (React render patterns).
|
|
63
|
-
'unicorn/no-nested-ternary': 'off',
|
|
64
|
-
// Allow Array.from — codebase uses it for iterables.
|
|
65
|
-
'unicorn/prefer-spread': 'off',
|
|
66
|
-
// Entire codebase uses PascalCase for TS files; kebab-case would require
|
|
67
|
-
// mass renames.
|
|
68
|
-
'unicorn/filename-case': 'off',
|
|
69
|
-
// Established names should not be force-renamed.
|
|
70
|
-
'unicorn/name-replacements': 'off',
|
|
71
|
-
// Zod schema builder chains and other deep method chains are intentional.
|
|
72
|
-
'unicorn/max-nested-calls': 'off',
|
|
73
|
-
// import.meta.dirname is not available in all test environments.
|
|
74
|
-
'unicorn/prefer-import-meta-properties': 'off',
|
|
75
|
-
// Codebase uses `err` as catch parameter name throughout.
|
|
76
|
-
'unicorn/catch-error-name': 'off',
|
|
77
|
-
// Established boolean param names (retryable, enabled, etc.).
|
|
78
|
-
'unicorn/consistent-boolean-name': 'off',
|
|
79
|
-
// Uint8Array#toBase64 / fromBase64 are not in all Workers runtime versions.
|
|
80
|
-
'unicorn/prefer-uint8array-base64': 'off',
|
|
81
|
-
// Class member ordering would require extensive restructuring.
|
|
82
|
-
'unicorn/consistent-class-member-order': 'off',
|
|
83
|
-
// API response fields use verb prefixes by convention.
|
|
84
|
-
'unicorn/no-non-function-verb-prefix': 'off',
|
|
85
|
-
// forEach is used intentionally throughout the provider and utility layers.
|
|
86
|
-
'unicorn/no-for-each': 'off',
|
|
87
|
-
// .then() chains in DAO and provider layers are often intentional.
|
|
88
|
-
'unicorn/prefer-await': 'warn',
|
|
89
|
-
// Callback references (e.g. .map(Number)) are sometimes intentional.
|
|
90
|
-
'unicorn/no-array-callback-reference': 'warn',
|
|
91
|
-
// toSorted() is ES2023 and may not be in all tsconfig lib targets.
|
|
92
|
-
'unicorn/no-array-sort': 'warn',
|
|
93
|
-
// Early-return guard clauses are the established style; the rule only
|
|
94
|
-
// rewrites the final guard of a ladder, which yields asymmetric mixed style
|
|
95
|
-
// and long inline ternaries. Off in Mail-Meow and Edge-Sonic; canonical here
|
|
96
|
-
// because it is the family's established style.
|
|
97
|
-
'unicorn/prefer-ternary': 'off',
|
|
98
|
-
// `(await x).y` -> a named intermediate. Fires constantly in the tests,
|
|
99
|
-
// where destructuring beside the assertion it serves is clearer.
|
|
100
|
-
'unicorn/no-await-expression-member': 'off',
|
|
101
|
-
// `Number(x)` over `+x`: the `+` form is used where an explicit typeof check
|
|
102
|
-
// has already narrowed the operand.
|
|
103
|
-
'unicorn/prefer-number-coercion': 'off',
|
|
104
|
-
// Code-point iteration: the byte-level readers index deliberately, because
|
|
105
|
-
// the offset *is* what they are reading.
|
|
106
|
-
'unicorn/prefer-code-point': 'off',
|
|
107
|
-
// `if (!x) return;` over a compound condition: one guard per line, each with
|
|
108
|
-
// its own comment, is what keeps endpoint guards readable.
|
|
109
|
-
'unicorn/prefer-simple-condition-first': 'off',
|
|
110
|
-
// Module-scope `let` assigned from `beforeEach` in the test harnesses.
|
|
111
|
-
'unicorn/no-top-level-assignment-in-function': 'off',
|
|
112
|
-
// Sequential `for...of` with `await` in the DAOs — D1's subrequest budget is
|
|
113
|
-
// the scarce resource.
|
|
114
|
-
'unicorn/no-unreadable-for-of-expression': 'off',
|
|
115
|
-
// `Object.hasOwn` over `in`: used where a prototype-chain hit is harmless.
|
|
116
|
-
'unicorn/no-computed-property-existence-check': 'off',
|
|
117
|
-
// A labeled `break` out of two loops.
|
|
118
|
-
'unicorn/no-break-in-nested-loop': 'off',
|
|
119
|
-
// `this` outside a class body: the module-level cache singletons document
|
|
120
|
-
// their `this` contract in prose.
|
|
121
|
-
'unicorn/no-this-outside-of-class': 'off',
|
|
122
|
-
// A class named inside its own static method.
|
|
123
|
-
'unicorn/class-reference-in-static-methods': 'off',
|
|
124
|
-
// Assigning `globalThis.fetch` in a test — the only way to intercept the
|
|
125
|
-
// ambient fetch in Node without a module mock.
|
|
126
|
-
'unicorn/no-global-object-property-assignment': 'off',
|
|
127
|
-
// `(a ? b : c) && d`: written longhand so each precedence decision is
|
|
128
|
-
// visible.
|
|
129
|
-
'unicorn/prefer-logical-operator-over-ternary': 'off',
|
|
130
|
-
// `children[0]` in the XML helpers, which index a child list positionally.
|
|
131
|
-
'unicorn/better-dom-traversing': 'off',
|
|
132
|
-
// `entries()` -> `keys()`/`values()`: the full entry is destructured.
|
|
133
|
-
'unicorn/prefer-iterator-to-array': 'off',
|
|
134
|
-
// `.map(fn, thisArg)`: rejected on purpose.
|
|
135
|
-
'unicorn/no-array-method-this-argument': 'off',
|
|
136
|
-
// A module-scope function that closes over nothing.
|
|
137
|
-
'unicorn/consistent-function-scoping': 'off',
|
|
138
|
-
// `foo[0] === 'a' || foo[0] === 'b'` written longhand where the
|
|
139
|
-
// alternatives are not adjacent.
|
|
140
|
-
'unicorn/prefer-includes-over-repeated-comparisons': 'off',
|
|
141
|
-
// A `type` alias over an inline union, where the name is what makes the
|
|
142
|
-
// signature and its doc comment readable.
|
|
143
|
-
'sonarjs/use-type-alias': 'off',
|
|
144
|
-
// A short local alias for a type imported from a protocol package.
|
|
145
|
-
'sonarjs/redundant-type-aliases': 'off',
|
|
146
|
-
// `type: value` narrowing the other way, where both spellings appear in the
|
|
147
|
-
// same schema and the code follows whichever the spec uses there.
|
|
148
|
-
'sonarjs/no-nested-assignment': 'off',
|
|
149
|
-
// `Number.isInteger` plus a separate range check, where the bounds come from
|
|
150
|
-
// the caller's own options in one place.
|
|
151
|
-
'unicorn/prefer-number-is-safe-integer': 'off',
|
|
152
|
-
// `\u{...}` over a `\xNN` escape: the table is written in the byte form the
|
|
153
|
-
// spec prints.
|
|
154
|
-
'unicorn/prefer-unicode-code-point-escapes': 'off',
|
|
155
|
-
// `self.x = this.x` in an entry model: the alias makes the verbatim
|
|
156
|
-
// round-trip explicit.
|
|
157
|
-
'unicorn/no-this-assignment': 'off',
|
|
158
|
-
// Building a `Set` at module scope from a constant list, for O(1) membership
|
|
159
|
-
// on a path that runs per parameter.
|
|
160
|
-
'unicorn/no-top-level-side-effects': 'off',
|
|
161
|
-
// A conditional whose branches are identical, kept where the two branches
|
|
162
|
-
// are named separately to document that they are meant to diverge.
|
|
163
|
-
'sonarjs/no-all-duplicated-branches': 'off',
|
|
164
|
-
// An `else` after a `return`: the flat form keeps the remaining cases at one
|
|
165
|
-
// indent level in the dispatch tables.
|
|
166
|
-
'unicorn/prefer-else-if': 'off',
|
|
167
|
-
// A nested ternary in a sort comparator, where the three-way order is the
|
|
168
|
-
// point.
|
|
169
|
-
'unicorn/prefer-minimal-ternary': 'off',
|
|
170
|
-
// `void promise` where initiating the call is the point and the rejection is
|
|
171
|
-
// handled at a named site elsewhere.
|
|
172
|
-
'sonarjs/void-use': 'off',
|
|
173
|
-
// `x === undefined` reported as always-true/false. With
|
|
174
|
-
// `noUncheckedIndexedAccess` on, the guard is exactly right.
|
|
175
|
-
'sonarjs/different-types-comparison': 'off',
|
|
176
|
-
// An accumulating loop with a sequential `await` in it, over D1 writes.
|
|
177
|
-
'unicorn/prefer-array-from-async': 'off',
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* SonarJS rules the sources turned from errors into advisories, with the
|
|
181
|
-
* threshold raised to a value that has actually held.
|
|
182
|
-
*/
|
|
183
|
-
export const SONARJS_RULES = {
|
|
184
|
-
// Raise duplicate-string threshold to avoid flagging intentional repeated
|
|
185
|
-
// literals like provider IDs.
|
|
186
|
-
'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }],
|
|
187
|
-
// Cognitive complexity — warn rather than error, so the ratchet can move
|
|
188
|
-
// without a red build. Raise the number only as files are decomposed.
|
|
189
|
-
'sonarjs/cognitive-complexity': ['warn', 20],
|
|
190
|
-
// False positives: connection method names like 'imap-password' and field
|
|
191
|
-
// names like 'password_hash'.
|
|
192
|
-
'sonarjs/no-hardcoded-passwords': 'off',
|
|
193
|
-
// Third-party deprecations are warnings, not errors.
|
|
194
|
-
'sonarjs/deprecation': 'warn',
|
|
195
|
-
// Nested ternaries in complex data-mapping code.
|
|
196
|
-
'sonarjs/no-nested-conditional': 'warn',
|
|
197
|
-
// React component props are commonly not marked Readonly<>.
|
|
198
|
-
'sonarjs/prefer-read-only-props': 'warn',
|
|
199
|
-
// Static readonly properties require invasive refactoring.
|
|
200
|
-
'sonarjs/public-static-readonly': 'warn',
|
|
201
|
-
// Nested template literals in SQL queries and prompt construction.
|
|
202
|
-
'sonarjs/no-nested-template-literals': 'warn',
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Test-suite overrides.
|
|
206
|
-
*
|
|
207
|
-
* `test/**` is deliberately *not* in the config's ignores list. Durable-DAV,
|
|
208
|
-
* AWS and Mail-Meow all ignored it, and ~200 KB of test code had accumulated
|
|
209
|
-
* violations that nothing reported. This block puts the suite back under the
|
|
210
|
-
* same rules as the rest of the workspace and switches off only the handful
|
|
211
|
-
* whose findings are structural artefacts of test code rather than defects.
|
|
212
|
-
* It does not disable correctness rules: the unused-variable, dead-store,
|
|
213
|
-
* regex and sorting findings in the suite are real and are fixed, not
|
|
214
|
-
* suppressed.
|
|
215
|
-
*/
|
|
216
|
-
export const TEST_RULES = {
|
|
217
|
-
// `it('…', async () => …)` is the Vitest idiom.
|
|
218
|
-
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { arguments: false, attributes: false } }],
|
|
219
|
-
// Unbound method is a common false positive in mock assertions like
|
|
220
|
-
// expect(fn).toHaveBeenCalledWith(...).
|
|
221
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
222
|
-
// Test helpers and stubs routinely use async functions without await.
|
|
223
|
-
'@typescript-eslint/require-await': 'off',
|
|
224
|
-
// Redundant type constituents appear in typed mock stubs.
|
|
225
|
-
'@typescript-eslint/no-redundant-type-constituents': 'off',
|
|
226
|
-
// `as never` casts are the standard fake-DB double pattern in tests.
|
|
227
|
-
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
|
228
|
-
// Promise.withResolvers() and function-scoping refactors are cosmetic.
|
|
229
|
-
'unicorn/prefer-promise-with-resolvers': 'off',
|
|
230
|
-
'unicorn/consistent-function-scoping': 'off',
|
|
231
|
-
// Fake-DB builders push-then-return and sort without comparators.
|
|
232
|
-
'unicorn/no-return-array-push': 'off',
|
|
233
|
-
'unicorn/require-array-sort-compare': 'off',
|
|
234
|
-
// Iterator-helper rewrites churn test fakes with no runtime benefit.
|
|
235
|
-
'unicorn/prefer-iterator-helpers': 'off',
|
|
236
|
-
'unicorn/prefer-iterator-to-array': 'off',
|
|
237
|
-
// String replacement with test-driven values is intentional in assertions.
|
|
238
|
-
'unicorn/no-unsafe-string-replacement': 'off',
|
|
239
|
-
// Fake-D1 doubles await a DAO thunk and call straight onto the result.
|
|
240
|
-
'unicorn/no-await-expression-member': 'off',
|
|
241
|
-
// `void promise` marks a deliberately unawaited promise in a test.
|
|
242
|
-
'sonarjs/void-use': 'off',
|
|
243
|
-
// A test asserting request routing has to name `http://` hosts, and a proxy
|
|
244
|
-
// test has to name a loopback upstream. Both are the subject matter, not
|
|
245
|
-
// leaked configuration. `unicorn/prefer-https` must stay off here and this
|
|
246
|
-
// is not a style preference: it rewrites `http://` to `https://` *inside
|
|
247
|
-
// string literals*, and `--fix` applies it silently.
|
|
248
|
-
'sonarjs/no-clear-text-protocols': 'off',
|
|
249
|
-
'sonarjs/no-hardcoded-ip': 'off',
|
|
250
|
-
'unicorn/prefer-https': 'off',
|
|
251
|
-
// sonarjs/assertions-in-tests fires false positives when test helpers handle
|
|
252
|
-
// assertions indirectly.
|
|
253
|
-
'sonarjs/assertions-in-tests': 'off',
|
|
254
|
-
// sonarjs/no-extra-arguments fires incorrectly on Vitest mock overloads.
|
|
255
|
-
'sonarjs/no-extra-arguments': 'off',
|
|
256
|
-
// Union/inline types in test fakes are more readable than aliases.
|
|
257
|
-
'sonarjs/use-type-alias': 'off',
|
|
258
|
-
// Alphabetical-sort rule fights deterministic fixture ordering.
|
|
259
|
-
'sonarjs/no-alphabetical-sort': 'off',
|
|
260
|
-
// Repeated string literals in fixtures/assertions are clearer inline.
|
|
261
|
-
'sonarjs/no-duplicate-string': 'off',
|
|
262
|
-
// Fake-D1 doubles break out of a nested loop to model a statement miss.
|
|
263
|
-
'unicorn/no-break-in-nested-loop': 'off',
|
|
264
|
-
// Fixtures are naturally built with sort()/for…of over composed expressions.
|
|
265
|
-
'unicorn/no-array-sort': 'off',
|
|
266
|
-
'unicorn/no-unreadable-for-of-expression': 'off',
|
|
267
|
-
'unicorn/no-useless-template-literals': 'off',
|
|
268
|
-
'unicorn/no-declarations-before-early-exit': 'off',
|
|
269
|
-
'unicorn/prefer-includes-over-repeated-comparisons': 'off',
|
|
270
|
-
'sonarjs/prefer-specific-assertions': 'off',
|
|
271
|
-
'sonarjs/no-inverted-boolean-check': 'off',
|
|
272
|
-
};
|
|
273
|
-
//# sourceMappingURL=eslint-rules.js.map
|
|
1
|
+
const n={"@typescript-eslint/no-unused-vars":["error",{argsIgnorePattern:"^_",varsIgnorePattern:"^_"}],"@typescript-eslint/no-floating-promises":["error",{ignoreVoid:!0}],"@typescript-eslint/no-explicit-any":"warn","@typescript-eslint/no-unsafe-assignment":"warn","@typescript-eslint/no-unsafe-member-access":"warn","@typescript-eslint/no-unsafe-call":"warn","@typescript-eslint/no-unsafe-return":"warn","@typescript-eslint/no-unsafe-argument":"warn","@typescript-eslint/no-misused-promises":["error",{checksVoidReturn:{attributes:!1,properties:!1}}],"@typescript-eslint/require-await":"off","@typescript-eslint/await-thenable":"off"},r={"unicorn/prevent-abbreviations":"off","unicorn/no-null":"off","unicorn/prefer-module":"off","unicorn/prefer-top-level-await":"off","unicorn/custom-error-definition":"off","unicorn/no-process-exit":"off","unicorn/no-array-reduce":"off","unicorn/prefer-number-properties":["error",{checkInfinity:!1}],"unicorn/no-nested-ternary":"off","unicorn/prefer-spread":"off","unicorn/filename-case":"off","unicorn/name-replacements":"off","unicorn/max-nested-calls":"off","unicorn/prefer-import-meta-properties":"off","unicorn/catch-error-name":"off","unicorn/consistent-boolean-name":"off","unicorn/prefer-uint8array-base64":"off","unicorn/consistent-class-member-order":"off","unicorn/no-non-function-verb-prefix":"off","unicorn/no-for-each":"off","unicorn/prefer-await":"warn","unicorn/no-array-callback-reference":"warn","unicorn/no-array-sort":"warn","unicorn/prefer-ternary":"off","unicorn/no-await-expression-member":"off","unicorn/prefer-number-coercion":"off","unicorn/prefer-code-point":"off","unicorn/prefer-simple-condition-first":"off","unicorn/no-top-level-assignment-in-function":"off","unicorn/no-unreadable-for-of-expression":"off","unicorn/no-computed-property-existence-check":"off","unicorn/no-break-in-nested-loop":"off","unicorn/no-this-outside-of-class":"off","unicorn/class-reference-in-static-methods":"off","unicorn/no-global-object-property-assignment":"off","unicorn/prefer-logical-operator-over-ternary":"off","unicorn/better-dom-traversing":"off","unicorn/prefer-iterator-to-array":"off","unicorn/no-array-method-this-argument":"off","unicorn/consistent-function-scoping":"off","unicorn/prefer-includes-over-repeated-comparisons":"off","sonarjs/use-type-alias":"off","sonarjs/redundant-type-aliases":"off","sonarjs/no-nested-assignment":"off","unicorn/prefer-number-is-safe-integer":"off","unicorn/prefer-unicode-code-point-escapes":"off","unicorn/no-this-assignment":"off","unicorn/no-top-level-side-effects":"off","sonarjs/no-all-duplicated-branches":"off","unicorn/prefer-else-if":"off","unicorn/prefer-minimal-ternary":"off","sonarjs/void-use":"off","sonarjs/different-types-comparison":"off","unicorn/prefer-array-from-async":"off"},o={"sonarjs/no-duplicate-string":["warn",{threshold:5}],"sonarjs/cognitive-complexity":["warn",20],"sonarjs/no-hardcoded-passwords":"off","sonarjs/deprecation":"warn","sonarjs/no-nested-conditional":"warn","sonarjs/prefer-read-only-props":"warn","sonarjs/public-static-readonly":"warn","sonarjs/no-nested-template-literals":"warn"},e={"@typescript-eslint/no-misused-promises":["error",{checksVoidReturn:{arguments:!1,attributes:!1}}],"@typescript-eslint/unbound-method":"off","@typescript-eslint/require-await":"off","@typescript-eslint/no-redundant-type-constituents":"off","@typescript-eslint/no-unnecessary-type-assertion":"off","unicorn/prefer-promise-with-resolvers":"off","unicorn/consistent-function-scoping":"off","unicorn/no-return-array-push":"off","unicorn/require-array-sort-compare":"off","unicorn/prefer-iterator-helpers":"off","unicorn/prefer-iterator-to-array":"off","unicorn/no-unsafe-string-replacement":"off","unicorn/no-await-expression-member":"off","sonarjs/void-use":"off","sonarjs/no-clear-text-protocols":"off","sonarjs/no-hardcoded-ip":"off","unicorn/prefer-https":"off","sonarjs/assertions-in-tests":"off","sonarjs/no-extra-arguments":"off","sonarjs/use-type-alias":"off","sonarjs/no-alphabetical-sort":"off","sonarjs/no-duplicate-string":"off","unicorn/no-break-in-nested-loop":"off","unicorn/no-array-sort":"off","unicorn/no-unreadable-for-of-expression":"off","unicorn/no-useless-template-literals":"off","unicorn/no-declarations-before-early-exit":"off","unicorn/prefer-includes-over-repeated-comparisons":"off","sonarjs/prefer-specific-assertions":"off","sonarjs/no-inverted-boolean-check":"off"};export{o as SONARJS_RULES,e as TEST_RULES,n as TYPESCRIPT_RULES,r as UNICORN_RULES};
|