@stardeck-customer-apps/eslint-plugin 1.2.0 → 1.6.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/LICENSE +21 -0
- package/SKILL.md +146 -0
- package/dist/index.cjs +461 -4
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +461 -4
- package/package.json +3 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stardeck Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# ESLint Plugin
|
|
2
|
+
|
|
3
|
+
Custom ESLint rules for Stardeck customer apps. Requires ESLint 9+ flat config.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @stardeck-customer-apps/eslint-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
// eslint.config.mjs
|
|
15
|
+
import stardeckEslint from "@stardeck-customer-apps/eslint-plugin";
|
|
16
|
+
|
|
17
|
+
export default [
|
|
18
|
+
// ... your other configs
|
|
19
|
+
stardeckEslint.configs.recommended,
|
|
20
|
+
];
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Rules
|
|
24
|
+
|
|
25
|
+
### `no-template-literal-classname`
|
|
26
|
+
|
|
27
|
+
Disallows template literal interpolation in `className`. Use `cn()` instead.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
// Bad
|
|
31
|
+
<div className={`px-4 ${isActive ? "bg-primary" : "bg-muted"}`} />
|
|
32
|
+
|
|
33
|
+
// Good
|
|
34
|
+
<div className={cn("px-4", isActive ? "bg-primary" : "bg-muted")} />
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Why?** Template literals in className break Tailwind IntelliSense and class merging.
|
|
38
|
+
|
|
39
|
+
### `no-kysely-interactive-transaction`
|
|
40
|
+
|
|
41
|
+
Disallows Kysely interactive and controlled transactions. The Kysely instance
|
|
42
|
+
returned by `createDataStore()` is backed by the Neon HTTP driver, which cannot
|
|
43
|
+
hold a transaction open across round-trips and throws at runtime:
|
|
44
|
+
|
|
45
|
+
> NeonDialect doesn't support interactive transactions, while Kysely doesn't support batch requests (yet).
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// Bad — throws at runtime
|
|
49
|
+
await db.transaction().execute(async (trx) => {
|
|
50
|
+
await trx.insertInto("orders").values(order).execute();
|
|
51
|
+
await trx.updateTable("inventory").set({ count }).execute();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Bad — controlled transactions are unsupported too
|
|
55
|
+
const trx = await db.startTransaction().execute();
|
|
56
|
+
|
|
57
|
+
// Good — fold the work into a single statement (CTE)
|
|
58
|
+
await db
|
|
59
|
+
.with("new_order", (qb) => qb.insertInto("orders").values(order).returning("id"))
|
|
60
|
+
.updateTable("inventory")
|
|
61
|
+
.set({ count })
|
|
62
|
+
.execute();
|
|
63
|
+
|
|
64
|
+
// Good — or run the statements sequentially
|
|
65
|
+
await db.insertInto("orders").values(order).execute();
|
|
66
|
+
await db.updateTable("inventory").set({ count }).execute();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Why?** Drizzle's `db.transaction(cb)` and the Neon client's `sql.transaction([...])`
|
|
70
|
+
take arguments, so only the zero-argument `db.transaction()` builder (and
|
|
71
|
+
`db.startTransaction()`) — the Kysely interactive/controlled APIs — are flagged.
|
|
72
|
+
|
|
73
|
+
### `no-module-internal-import`
|
|
74
|
+
|
|
75
|
+
Vendored modules live at `src/modules/<name>/` with `index.ts` as the only public
|
|
76
|
+
surface. Import other modules (and modules from app code) only through that index —
|
|
77
|
+
e.g. `@/modules/booking`. Deep paths like `@/modules/booking/server/reservations`
|
|
78
|
+
are an error (including type imports, `export * from`, and dynamic `import()`).
|
|
79
|
+
A file inside a module may still import its own internals freely.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// Bad — reaches into module internals
|
|
83
|
+
import { list } from "@/modules/booking/server/reservations";
|
|
84
|
+
|
|
85
|
+
// Good — public surface only
|
|
86
|
+
import { listReservations } from "@/modules/booking";
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Why?** Deep imports break module install/update isolation by coupling callers to
|
|
90
|
+
files that can move or disappear when the module is swapped.
|
|
91
|
+
|
|
92
|
+
### `no-server-import-in-conventional-entry`
|
|
93
|
+
|
|
94
|
+
`contributions.ts` and `slots.ts` (root, or enhancement-scoped `contributions.ts`)
|
|
95
|
+
are bundled into client-reachable composition artifacts. They must not directly
|
|
96
|
+
import `server-only`, a Node builtin, a `.server` file, any `/server` module
|
|
97
|
+
entry, or an enhancement root barrel (which may re-export `initialize.server`).
|
|
98
|
+
`initialize.server.ts` itself is server-only by design and is not linted by
|
|
99
|
+
this rule.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
// contributions.ts — Bad
|
|
103
|
+
import "server-only";
|
|
104
|
+
import fs from "node:fs";
|
|
105
|
+
import { handlers } from "@/modules/booking/server";
|
|
106
|
+
import { initializeEnhancement } from "./initialize.server";
|
|
107
|
+
|
|
108
|
+
// contributions.ts — Good
|
|
109
|
+
import { z } from "zod";
|
|
110
|
+
import { helper } from "./helpers";
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Why?** This is the immediate-import lint signal for a fail-closed contract also
|
|
114
|
+
enforced by canonical AST evidence in the module structure collector and the
|
|
115
|
+
install rail. Only the direct specifier is checked — it does not prove the
|
|
116
|
+
entry's full import graph never reaches server code (that's the real Next
|
|
117
|
+
client-build seam's job) — so do not add exemptions here to work around it.
|
|
118
|
+
|
|
119
|
+
### `rail-marker-congruent`
|
|
120
|
+
|
|
121
|
+
A `// @stardeck-module-rail-generated ...` first line means the module install
|
|
122
|
+
rail owns the file. The marker's kind must match the file's path shape:
|
|
123
|
+
`scope=root` / `scope=enhancement:<peer>` only on `src/app/api/**/route.ts`,
|
|
124
|
+
`scope=route path=<route>` only on `src/app/<route>/page.tsx` with a matching
|
|
125
|
+
`path=`, and the ownerless scopes only on their `src/*.gen.ts` file. The five `src/*.gen.ts`
|
|
126
|
+
files must always carry their marker; a marker-less one is reported too.
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
// src/app/(admin)/admin/finance/assets/page.tsx — Bad
|
|
130
|
+
// @stardeck-module-rail-generated owner=finance scope=root
|
|
131
|
+
|
|
132
|
+
// src/app/(admin)/admin/finance/assets/page.tsx — Good
|
|
133
|
+
// @stardeck-module-rail-generated owner=finance scope=route path=(admin)/admin/finance/assets
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Why?** Blueprint publish regenerates module artifacts and fails closed on a
|
|
137
|
+
swapped marker ("incongruent marker at ... refusing to reconcile"). Catching it
|
|
138
|
+
at lint time is faster than a failed publish. Fix by deleting the marker line if
|
|
139
|
+
the file is hand-written, or restoring the generated stub.
|
|
140
|
+
|
|
141
|
+
## Disable for a Line
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
// eslint-disable-next-line @stardeck-customer-apps/eslint-plugin/no-template-literal-classname
|
|
145
|
+
<div className={`legacy ${dynamicClass}`} />
|
|
146
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -139,8 +139,13 @@ function findSrcRoot(filename) {
|
|
|
139
139
|
for (let i = 0; i < parts.length; i++) {
|
|
140
140
|
if (parts[i] === "src") lastSrcIdx = i;
|
|
141
141
|
}
|
|
142
|
-
if (lastSrcIdx
|
|
143
|
-
|
|
142
|
+
if (lastSrcIdx !== -1) return parts.slice(0, lastSrcIdx + 1).join("/");
|
|
143
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
144
|
+
if (parts[i] === "apps" && parts[i + 1] === "web") {
|
|
145
|
+
return parts.slice(0, i + 2).concat("src").join("/");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
144
149
|
}
|
|
145
150
|
function normalizePosixPath(raw) {
|
|
146
151
|
const absolute = raw.startsWith("/");
|
|
@@ -193,6 +198,99 @@ function isPublicSurface(resolvedPath, srcRoot, moduleName) {
|
|
|
193
198
|
if (resolvedPath === `${base}/index.tsx`) return true;
|
|
194
199
|
return false;
|
|
195
200
|
}
|
|
201
|
+
function isModuleRoutesEntry(resolvedPath, srcRoot, moduleName) {
|
|
202
|
+
const prefix = `${srcRoot}/modules/${moduleName}/routes/`;
|
|
203
|
+
return resolvedPath === `${srcRoot}/modules/${moduleName}/routes` || resolvedPath.startsWith(prefix);
|
|
204
|
+
}
|
|
205
|
+
var RAIL_MARKER = "@stardeck-module-rail-generated";
|
|
206
|
+
var I18N_GEN_MARKER = `// ${RAIL_MARKER} scope=i18n`;
|
|
207
|
+
var LOCALE_BASENAME_REGEX = /^[a-z]{2,3}(?:-[A-Za-z0-9]+)*$/;
|
|
208
|
+
var MAX_LOCALE_BASENAME_LENGTH = 35;
|
|
209
|
+
function isRailGeneratedRouteStub(filename, sourceText) {
|
|
210
|
+
const posix = toPosix(filename);
|
|
211
|
+
if (!/\/src\/app\/.+\/page\.tsx$/.test(posix) && !/\/src\/app\/page\.tsx$/.test(posix)) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const firstLine = sourceText.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
215
|
+
return firstLine.startsWith(`// ${RAIL_MARKER} `) && firstLine.includes("scope=route ");
|
|
216
|
+
}
|
|
217
|
+
function isRailGeneratedCompositionImporter(filename, sourceText) {
|
|
218
|
+
const posix = toPosix(filename);
|
|
219
|
+
if (!/\/src\/(?:modules\.gen|module-contributions\.gen|module-i18n\.gen|module-init\.server\.gen)\.ts$/.test(
|
|
220
|
+
posix
|
|
221
|
+
)) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
const firstLine = sourceText.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
225
|
+
if (!firstLine.startsWith(`// ${RAIL_MARKER} `)) return false;
|
|
226
|
+
return firstLine.includes("scope=contributions") || firstLine.includes("scope=i18n") || firstLine.includes("scope=init") || firstLine.includes("scope=registry");
|
|
227
|
+
}
|
|
228
|
+
function isConventionalCompositionEntry(resolvedPath, srcRoot, moduleName) {
|
|
229
|
+
const base = `${srcRoot}/modules/${moduleName}`;
|
|
230
|
+
const allowedExact = /* @__PURE__ */ new Set([
|
|
231
|
+
`${base}/contributions`,
|
|
232
|
+
`${base}/contributions.ts`,
|
|
233
|
+
`${base}/slots`,
|
|
234
|
+
`${base}/slots.ts`,
|
|
235
|
+
`${base}/i18n`,
|
|
236
|
+
`${base}/i18n/index`,
|
|
237
|
+
`${base}/i18n/index.ts`
|
|
238
|
+
]);
|
|
239
|
+
if (allowedExact.has(resolvedPath)) return true;
|
|
240
|
+
const enhMatch = resolvedPath.match(
|
|
241
|
+
new RegExp(
|
|
242
|
+
`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/enhancements/([^/]+)/(contributions|initialize\\.server)(?:\\.ts)?$`
|
|
243
|
+
)
|
|
244
|
+
);
|
|
245
|
+
if (enhMatch) return true;
|
|
246
|
+
const enhI18n = resolvedPath.match(
|
|
247
|
+
new RegExp(
|
|
248
|
+
`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/enhancements/([^/]+)/i18n(?:/index(?:\\.ts)?)?$`
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
return Boolean(enhI18n);
|
|
252
|
+
}
|
|
253
|
+
function isRailGeneratedI18nJsonImporter(filename, sourceText) {
|
|
254
|
+
const posix = toPosix(filename);
|
|
255
|
+
if (!/\/src\/module-i18n\.gen\.ts$/.test(posix)) return false;
|
|
256
|
+
const firstLine = sourceText.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
257
|
+
return firstLine === I18N_GEN_MARKER;
|
|
258
|
+
}
|
|
259
|
+
function localeBasenameFromI18nJsonPath(resolvedPath, srcRoot, moduleName) {
|
|
260
|
+
const base = `${srcRoot}/modules/${moduleName}`;
|
|
261
|
+
const escaped = base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
262
|
+
const rootMatch = new RegExp(`^${escaped}/i18n/([^/]+)\\.json$`).exec(resolvedPath);
|
|
263
|
+
if (rootMatch) return rootMatch[1] ?? null;
|
|
264
|
+
const sliceMatch = new RegExp(`^${escaped}/enhancements/[^/]+/i18n/([^/]+)\\.json$`).exec(
|
|
265
|
+
resolvedPath
|
|
266
|
+
);
|
|
267
|
+
return sliceMatch ? sliceMatch[1] ?? null : null;
|
|
268
|
+
}
|
|
269
|
+
function isValidLocaleBasename(basename) {
|
|
270
|
+
return basename.length > 0 && basename.length <= MAX_LOCALE_BASENAME_LENGTH && LOCALE_BASENAME_REGEX.test(basename);
|
|
271
|
+
}
|
|
272
|
+
function isConventionalI18nJsonEntry(resolvedPath, srcRoot, moduleName) {
|
|
273
|
+
const basename = localeBasenameFromI18nJsonPath(resolvedPath, srcRoot, moduleName);
|
|
274
|
+
return basename != null && isValidLocaleBasename(basename);
|
|
275
|
+
}
|
|
276
|
+
function isRailGeneratedEndpointStub(filename, sourceText) {
|
|
277
|
+
const posix = toPosix(filename);
|
|
278
|
+
if (!/\/src\/app\/api\/.+\/route\.ts$/.test(posix)) return false;
|
|
279
|
+
const firstLine = sourceText.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
280
|
+
return firstLine.startsWith(`// ${RAIL_MARKER} `) && (firstLine.includes("scope=root") || firstLine.includes("scope=enhancement:"));
|
|
281
|
+
}
|
|
282
|
+
function isEndpointHandlerEntry(resolvedPath, srcRoot, moduleName) {
|
|
283
|
+
const base = `${srcRoot}/modules/${moduleName}`;
|
|
284
|
+
if (resolvedPath === `${base}/server` || resolvedPath === `${base}/server/index` || resolvedPath === `${base}/server/index.ts`) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
const enh = resolvedPath.match(
|
|
288
|
+
new RegExp(
|
|
289
|
+
`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/enhancements/([^/]+)(?:/index(?:\\.ts)?)?$`
|
|
290
|
+
)
|
|
291
|
+
);
|
|
292
|
+
return Boolean(enh);
|
|
293
|
+
}
|
|
196
294
|
var rule3 = {
|
|
197
295
|
meta: {
|
|
198
296
|
type: "problem",
|
|
@@ -216,6 +314,11 @@ var rule3 = {
|
|
|
216
314
|
}
|
|
217
315
|
const root = srcRoot;
|
|
218
316
|
const importerModule = getModuleName(toPosix(filename), root);
|
|
317
|
+
const sourceText = context.sourceCode.getText();
|
|
318
|
+
const railRouteStub = isRailGeneratedRouteStub(filename, sourceText);
|
|
319
|
+
const railCompositionImporter = isRailGeneratedCompositionImporter(filename, sourceText);
|
|
320
|
+
const railI18nJsonImporter = isRailGeneratedI18nJsonImporter(filename, sourceText);
|
|
321
|
+
const railEndpointStub = isRailGeneratedEndpointStub(filename, sourceText);
|
|
219
322
|
function check(node, sourceNode) {
|
|
220
323
|
if (!sourceNode || sourceNode.type !== "Literal") return;
|
|
221
324
|
const value = sourceNode.value;
|
|
@@ -226,6 +329,14 @@ var rule3 = {
|
|
|
226
329
|
if (!targetModule) return;
|
|
227
330
|
if (isPublicSurface(resolved, root, targetModule)) return;
|
|
228
331
|
if (importerModule === targetModule) return;
|
|
332
|
+
if (railRouteStub && isModuleRoutesEntry(resolved, root, targetModule)) return;
|
|
333
|
+
if (railCompositionImporter && isConventionalCompositionEntry(resolved, root, targetModule)) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (railI18nJsonImporter && isConventionalI18nJsonEntry(resolved, root, targetModule)) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
if (railEndpointStub && isEndpointHandlerEntry(resolved, root, targetModule)) return;
|
|
229
340
|
context.report({
|
|
230
341
|
node,
|
|
231
342
|
messageId: "noInternalImport",
|
|
@@ -245,17 +356,361 @@ var rule3 = {
|
|
|
245
356
|
},
|
|
246
357
|
ExportAllDeclaration(node) {
|
|
247
358
|
check(node, node.source);
|
|
359
|
+
},
|
|
360
|
+
// Literal CommonJS `require("...")` — same isolation rule as ESM imports.
|
|
361
|
+
CallExpression(node) {
|
|
362
|
+
const call = node;
|
|
363
|
+
if (call.callee?.type !== "Identifier" || call.callee.name !== "require") return;
|
|
364
|
+
const arg0 = call.arguments?.[0];
|
|
365
|
+
if (!arg0 || arg0.type !== "Literal" || typeof arg0.value !== "string") return;
|
|
366
|
+
check(node, arg0);
|
|
367
|
+
},
|
|
368
|
+
// TypeScript `import x = require("...")` (TS-ESLint AST).
|
|
369
|
+
TSImportEqualsDeclaration(node) {
|
|
370
|
+
const decl = node;
|
|
371
|
+
const ref = decl.moduleReference;
|
|
372
|
+
if (!ref || ref.type !== "TSExternalModuleReference") return;
|
|
373
|
+
const expression = ref.expression;
|
|
374
|
+
if (!expression || expression.type !== "Literal" || typeof expression.value !== "string") {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
check(node, expression);
|
|
248
378
|
}
|
|
249
379
|
};
|
|
250
380
|
}
|
|
251
381
|
};
|
|
252
382
|
var no_module_internal_import_default = rule3;
|
|
253
383
|
|
|
384
|
+
// src/rules/no-server-import-in-conventional-entry.ts
|
|
385
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
386
|
+
function toPosix2(filePath) {
|
|
387
|
+
return filePath.split(import_node_path2.default.sep).join("/");
|
|
388
|
+
}
|
|
389
|
+
function isClientSafeConventionalEntry(filename) {
|
|
390
|
+
const posix = toPosix2(filename);
|
|
391
|
+
return /\/src\/modules\/[^/]+\/(?:contributions|slots)\.ts$/.test(posix) || /\/src\/modules\/[^/]+\/enhancements\/[^/]+\/contributions\.ts$/.test(posix);
|
|
392
|
+
}
|
|
393
|
+
var NODE_BUILTIN_MODULE_NAMES = /* @__PURE__ */ new Set([
|
|
394
|
+
"assert",
|
|
395
|
+
"async_hooks",
|
|
396
|
+
"buffer",
|
|
397
|
+
"child_process",
|
|
398
|
+
"cluster",
|
|
399
|
+
"console",
|
|
400
|
+
"constants",
|
|
401
|
+
"crypto",
|
|
402
|
+
"dgram",
|
|
403
|
+
"diagnostics_channel",
|
|
404
|
+
"dns",
|
|
405
|
+
"domain",
|
|
406
|
+
"events",
|
|
407
|
+
"fs",
|
|
408
|
+
"http",
|
|
409
|
+
"http2",
|
|
410
|
+
"https",
|
|
411
|
+
"inspector",
|
|
412
|
+
"module",
|
|
413
|
+
"net",
|
|
414
|
+
"os",
|
|
415
|
+
"path",
|
|
416
|
+
"perf_hooks",
|
|
417
|
+
"process",
|
|
418
|
+
"punycode",
|
|
419
|
+
"querystring",
|
|
420
|
+
"readline",
|
|
421
|
+
"repl",
|
|
422
|
+
"stream",
|
|
423
|
+
"string_decoder",
|
|
424
|
+
"sys",
|
|
425
|
+
"timers",
|
|
426
|
+
"tls",
|
|
427
|
+
"trace_events",
|
|
428
|
+
"tty",
|
|
429
|
+
"url",
|
|
430
|
+
"util",
|
|
431
|
+
"v8",
|
|
432
|
+
"vm",
|
|
433
|
+
"wasi",
|
|
434
|
+
"worker_threads",
|
|
435
|
+
"zlib"
|
|
436
|
+
]);
|
|
437
|
+
function isNodeBuiltinImportSpecifier(specifier) {
|
|
438
|
+
const withoutNodePrefix = specifier.startsWith("node:") ? specifier.slice("node:".length) : specifier;
|
|
439
|
+
if (withoutNodePrefix.startsWith("@")) return false;
|
|
440
|
+
const firstSegment = withoutNodePrefix.split("/")[0] ?? withoutNodePrefix;
|
|
441
|
+
return specifier.startsWith("node:") || NODE_BUILTIN_MODULE_NAMES.has(firstSegment);
|
|
442
|
+
}
|
|
443
|
+
function classifyForbiddenSpecifier(specifier) {
|
|
444
|
+
if (specifier === "server-only") {
|
|
445
|
+
return {
|
|
446
|
+
reason: "server-only-package",
|
|
447
|
+
message: `import of "server-only" package "${specifier}" is forbidden in a client-safe conventional entry`
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
if (isNodeBuiltinImportSpecifier(specifier)) {
|
|
451
|
+
return {
|
|
452
|
+
reason: "node-builtin",
|
|
453
|
+
message: `import of Node builtin "${specifier}" is forbidden in a client-safe conventional entry`
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
const pathPart = specifier.split(/[?#]/, 1)[0] ?? specifier;
|
|
457
|
+
const segments = pathPart.split("/").filter((s) => s.length > 0 && s !== ".");
|
|
458
|
+
if (/\.server(?:\.[cm]?[tj]sx?)?$/.test(pathPart)) {
|
|
459
|
+
return {
|
|
460
|
+
reason: "dot-server-file",
|
|
461
|
+
message: `import of a ".server" file "${specifier}" is forbidden in a client-safe conventional entry`
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
if (segments.some((seg) => seg === "server")) {
|
|
465
|
+
return {
|
|
466
|
+
reason: "server-path-segment",
|
|
467
|
+
message: `import reaching a "/server" module entry "${specifier}" is forbidden in a client-safe conventional entry`
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
const enhIdx = segments.lastIndexOf("enhancements");
|
|
471
|
+
if (enhIdx !== -1) {
|
|
472
|
+
const rest = segments.slice(enhIdx + 1);
|
|
473
|
+
const isRootBarrel = rest.length === 1 || rest.length === 2 && (rest[1] === "index" || rest[1] === "index.ts");
|
|
474
|
+
if (isRootBarrel) {
|
|
475
|
+
return {
|
|
476
|
+
reason: "enhancement-root-entry",
|
|
477
|
+
message: `import of enhancement root entry "${specifier}" is forbidden in a client-safe conventional entry (may carry server initialization)`
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
var rule4 = {
|
|
484
|
+
meta: {
|
|
485
|
+
type: "problem",
|
|
486
|
+
docs: {
|
|
487
|
+
description: "Disallow direct server-only / node builtin / .server / /server / enhancement-root imports inside contributions.ts and slots.ts, which are bundled into client-reachable composition artifacts",
|
|
488
|
+
recommended: true
|
|
489
|
+
},
|
|
490
|
+
messages: {
|
|
491
|
+
forbiddenServerImport: "{{message}}"
|
|
492
|
+
},
|
|
493
|
+
schema: []
|
|
494
|
+
},
|
|
495
|
+
create(context) {
|
|
496
|
+
const filename = context.filename;
|
|
497
|
+
if (!filename || filename === "<input>" || filename === "<text>") {
|
|
498
|
+
return {};
|
|
499
|
+
}
|
|
500
|
+
if (!isClientSafeConventionalEntry(filename)) {
|
|
501
|
+
return {};
|
|
502
|
+
}
|
|
503
|
+
function check(node, sourceNode) {
|
|
504
|
+
if (!sourceNode || sourceNode.type !== "Literal") return;
|
|
505
|
+
const value = sourceNode.value;
|
|
506
|
+
if (typeof value !== "string") return;
|
|
507
|
+
const forbidden = classifyForbiddenSpecifier(value);
|
|
508
|
+
if (!forbidden) return;
|
|
509
|
+
context.report({
|
|
510
|
+
node,
|
|
511
|
+
messageId: "forbiddenServerImport",
|
|
512
|
+
data: { message: forbidden.message }
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
ImportDeclaration(node) {
|
|
517
|
+
check(node, node.source);
|
|
518
|
+
},
|
|
519
|
+
ImportExpression(node) {
|
|
520
|
+
const src = node.source;
|
|
521
|
+
check(node, src);
|
|
522
|
+
},
|
|
523
|
+
ExportNamedDeclaration(node) {
|
|
524
|
+
check(node, node.source);
|
|
525
|
+
},
|
|
526
|
+
ExportAllDeclaration(node) {
|
|
527
|
+
check(node, node.source);
|
|
528
|
+
},
|
|
529
|
+
// Literal CommonJS `require("...")` — same client-bundle risk as ESM import.
|
|
530
|
+
CallExpression(node) {
|
|
531
|
+
const call = node;
|
|
532
|
+
if (call.callee?.type !== "Identifier" || call.callee.name !== "require") return;
|
|
533
|
+
const arg0 = call.arguments?.[0];
|
|
534
|
+
if (!arg0 || arg0.type !== "Literal" || typeof arg0.value !== "string") return;
|
|
535
|
+
const forbidden = classifyForbiddenSpecifier(arg0.value);
|
|
536
|
+
if (!forbidden) return;
|
|
537
|
+
context.report({
|
|
538
|
+
node,
|
|
539
|
+
messageId: "forbiddenServerImport",
|
|
540
|
+
data: { message: forbidden.message }
|
|
541
|
+
});
|
|
542
|
+
},
|
|
543
|
+
// TypeScript `import x = require("...")` (TS-ESLint AST).
|
|
544
|
+
TSImportEqualsDeclaration(node) {
|
|
545
|
+
const decl = node;
|
|
546
|
+
const ref = decl.moduleReference;
|
|
547
|
+
if (!ref || ref.type !== "TSExternalModuleReference") return;
|
|
548
|
+
const expr = ref.expression;
|
|
549
|
+
if (!expr || expr.type !== "Literal" || typeof expr.value !== "string") return;
|
|
550
|
+
const forbidden = classifyForbiddenSpecifier(expr.value);
|
|
551
|
+
if (!forbidden) return;
|
|
552
|
+
context.report({
|
|
553
|
+
node,
|
|
554
|
+
messageId: "forbiddenServerImport",
|
|
555
|
+
data: { message: forbidden.message }
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
var no_server_import_in_conventional_entry_default = rule4;
|
|
562
|
+
|
|
563
|
+
// src/rules/rail-marker-congruent.ts
|
|
564
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
565
|
+
var MARKER = "@stardeck-module-rail-generated";
|
|
566
|
+
var MARKER_RE = new RegExp(
|
|
567
|
+
`^//\\s*${MARKER}\\s+(?:owner=([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\\s+)?scope=(\\S+)(?:\\s+path=(.+))?$`
|
|
568
|
+
);
|
|
569
|
+
var OWNERLESS_SCOPES = {
|
|
570
|
+
registry: "registry",
|
|
571
|
+
contributions: "contributions",
|
|
572
|
+
datastores: "datastores",
|
|
573
|
+
i18n: "i18n",
|
|
574
|
+
init: "init"
|
|
575
|
+
};
|
|
576
|
+
var GEN_FILE_KINDS = {
|
|
577
|
+
"modules.gen.ts": "registry",
|
|
578
|
+
"module-contributions.gen.ts": "contributions",
|
|
579
|
+
"module-datastores.gen.ts": "datastores",
|
|
580
|
+
"module-i18n.gen.ts": "i18n",
|
|
581
|
+
"module-init.server.gen.ts": "init"
|
|
582
|
+
};
|
|
583
|
+
var METHODS = "GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS";
|
|
584
|
+
var OWNER = "[a-z][a-z0-9]*(?:-[a-z0-9]+)*";
|
|
585
|
+
function isLegacyApiAdapterBody(source, owner) {
|
|
586
|
+
const lines = source.replace(/\r\n/g, "\n").split("\n").slice(1).map((line) => line.trim()).filter(Boolean);
|
|
587
|
+
const importMatch = lines[0]?.match(
|
|
588
|
+
new RegExp(
|
|
589
|
+
`^import \\{ (endpointHandlers|production(?:[A-Z][A-Za-z0-9]*)?Handlers) \\} from "(@/modules/${owner}/server|@/modules/${owner}/enhancements/${OWNER}|@/lib/${owner}-wiring)";$`
|
|
590
|
+
)
|
|
591
|
+
);
|
|
592
|
+
if (!importMatch) return false;
|
|
593
|
+
const binding = importMatch[1];
|
|
594
|
+
const exports2 = lines.slice(1);
|
|
595
|
+
return exports2.length > 0 && exports2.every(
|
|
596
|
+
(line) => new RegExp(`^export const (${METHODS}) = ${binding}\\.\\1_[A-Za-z0-9_]+;$`).test(line)
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
function isLegacyRouteAdapterBody(source, routePath) {
|
|
600
|
+
return new RegExp(
|
|
601
|
+
`^// ${MARKER} scope=routes
|
|
602
|
+
/\\*\\* DO NOT EDIT \u2014 owned by the module install rail\\. \\*/
|
|
603
|
+
export \\{ default \\} from "@/modules/${OWNER}/routes/${routePath.replace(/[.*+?^$()[\]{}|]/g, "\\$&")}/page";
|
|
604
|
+
?$`
|
|
605
|
+
).test(source.replace(/\r\n/g, "\n"));
|
|
606
|
+
}
|
|
607
|
+
function parseMarker(source) {
|
|
608
|
+
const firstLine = source.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
609
|
+
const match = firstLine.match(MARKER_RE);
|
|
610
|
+
if (!match) return null;
|
|
611
|
+
const [, owner, scope, routePath] = match;
|
|
612
|
+
const ownerless = OWNERLESS_SCOPES[scope];
|
|
613
|
+
if (ownerless) return owner ? null : { kind: ownerless };
|
|
614
|
+
if (scope === "routes") return owner ? null : { kind: "route", legacyRoute: true };
|
|
615
|
+
if (!owner) return null;
|
|
616
|
+
if (scope === "route") {
|
|
617
|
+
const trimmed = routePath?.trim();
|
|
618
|
+
return trimmed ? { kind: "route", routePath: trimmed, owner } : null;
|
|
619
|
+
}
|
|
620
|
+
if (scope === "root" || scope.startsWith("enhancement:")) return { kind: "endpoint", owner };
|
|
621
|
+
return null;
|
|
622
|
+
}
|
|
623
|
+
function shapeForPath(filename) {
|
|
624
|
+
const posix = filename.split(import_node_path3.default.sep).join("/");
|
|
625
|
+
const gen = posix.match(/\/src\/([^/]+\.gen\.ts)$/);
|
|
626
|
+
if (gen) {
|
|
627
|
+
const kind = GEN_FILE_KINDS[gen[1]];
|
|
628
|
+
return kind ? { kind } : null;
|
|
629
|
+
}
|
|
630
|
+
const idx = posix.lastIndexOf("/src/app/");
|
|
631
|
+
if (idx < 0) return null;
|
|
632
|
+
const rest = posix.slice(idx + "/src/app/".length);
|
|
633
|
+
if (rest.startsWith("api/")) {
|
|
634
|
+
const m2 = rest.match(/^(.+)\/route\.ts$/);
|
|
635
|
+
return m2 ? { kind: "endpoint", routePath: m2[1] } : null;
|
|
636
|
+
}
|
|
637
|
+
const m = rest.match(/^(?:(.*)\/)?page\.(?:tsx|ts|jsx|js)$/);
|
|
638
|
+
return m ? { kind: "route", routePath: m[1] ?? "" } : null;
|
|
639
|
+
}
|
|
640
|
+
var rule5 = {
|
|
641
|
+
meta: {
|
|
642
|
+
type: "problem",
|
|
643
|
+
docs: {
|
|
644
|
+
description: "Require a @stardeck-module-rail-generated marker to match the file's path shape, so Blueprint publish can reconcile the file",
|
|
645
|
+
recommended: true
|
|
646
|
+
},
|
|
647
|
+
messages: {
|
|
648
|
+
wrongKind: "Found a {{found}} rail marker on a path shaped for {{expected}} artifacts. Blueprint publish will refuse to reconcile a swapped marker. Delete the marker line if this file is hand-written, or restore the generated stub.",
|
|
649
|
+
missingMarker: "Generated file {{file}} has no @stardeck-module-rail-generated marker on line 1. Blueprint publish will refuse to overwrite it as unmanaged. Restore the marker line (or the whole generated file) rather than editing it by hand.",
|
|
650
|
+
legacyRouteBody: "Rail marker scope=routes is only valid with its original body: the DO NOT EDIT line and a single default re-export of this route's page from its Module. Blueprint publish treats anything else as unmanaged. Delete the marker line if this file is hand-written, or restore the generated stub.",
|
|
651
|
+
wrongRoutePath: 'Rail route marker claims path="{{claimed}}" but this file serves "{{actual}}". Blueprint publish will refuse to reconcile it. Delete the marker line if this file is hand-written, or restore the generated stub.'
|
|
652
|
+
},
|
|
653
|
+
schema: []
|
|
654
|
+
},
|
|
655
|
+
create(context) {
|
|
656
|
+
const filename = context.filename;
|
|
657
|
+
if (!filename || filename === "<input>" || filename === "<text>") return {};
|
|
658
|
+
const shape = shapeForPath(filename);
|
|
659
|
+
if (!shape) return {};
|
|
660
|
+
return {
|
|
661
|
+
Program(node) {
|
|
662
|
+
const marker = parseMarker(context.sourceCode.text);
|
|
663
|
+
const loc = { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } };
|
|
664
|
+
if (!marker) {
|
|
665
|
+
if (GEN_FILE_KINDS[import_node_path3.default.basename(filename)]) {
|
|
666
|
+
context.report({
|
|
667
|
+
node,
|
|
668
|
+
loc,
|
|
669
|
+
messageId: "missingMarker",
|
|
670
|
+
data: { file: import_node_path3.default.basename(filename) }
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (marker.kind !== shape.kind) {
|
|
676
|
+
if (shape.kind === "endpoint" && marker.kind === "route" && marker.routePath === shape.routePath && isLegacyApiAdapterBody(context.sourceCode.text, marker.owner)) {
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
context.report({
|
|
680
|
+
node,
|
|
681
|
+
loc,
|
|
682
|
+
messageId: "wrongKind",
|
|
683
|
+
data: { found: marker.kind, expected: shape.kind }
|
|
684
|
+
});
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (marker.legacyRoute) {
|
|
688
|
+
if (!isLegacyRouteAdapterBody(context.sourceCode.text, shape.routePath ?? "")) {
|
|
689
|
+
context.report({ node, loc, messageId: "legacyRouteBody" });
|
|
690
|
+
}
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
if (marker.kind === "route" && marker.routePath !== shape.routePath) {
|
|
694
|
+
context.report({
|
|
695
|
+
node,
|
|
696
|
+
loc,
|
|
697
|
+
messageId: "wrongRoutePath",
|
|
698
|
+
data: { claimed: marker.routePath ?? "", actual: shape.routePath ?? "" }
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
var rail_marker_congruent_default = rule5;
|
|
706
|
+
|
|
254
707
|
// src/rules/index.ts
|
|
255
708
|
var rules = {
|
|
256
709
|
"no-template-literal-classname": no_template_literal_classname_default,
|
|
257
710
|
"no-kysely-interactive-transaction": no_kysely_interactive_transaction_default,
|
|
258
|
-
"no-module-internal-import": no_module_internal_import_default
|
|
711
|
+
"no-module-internal-import": no_module_internal_import_default,
|
|
712
|
+
"no-server-import-in-conventional-entry": no_server_import_in_conventional_entry_default,
|
|
713
|
+
"rail-marker-congruent": rail_marker_congruent_default
|
|
259
714
|
};
|
|
260
715
|
|
|
261
716
|
// src/configs/recommended.ts
|
|
@@ -269,7 +724,9 @@ var recommended = {
|
|
|
269
724
|
rules: {
|
|
270
725
|
[`${pluginName}/no-template-literal-classname`]: "error",
|
|
271
726
|
[`${pluginName}/no-kysely-interactive-transaction`]: "error",
|
|
272
|
-
[`${pluginName}/no-module-internal-import`]: "error"
|
|
727
|
+
[`${pluginName}/no-module-internal-import`]: "error",
|
|
728
|
+
[`${pluginName}/no-server-import-in-conventional-entry`]: "error",
|
|
729
|
+
[`${pluginName}/rail-marker-congruent`]: "error"
|
|
273
730
|
}
|
|
274
731
|
};
|
|
275
732
|
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,8 @@ declare const rules: {
|
|
|
5
5
|
"no-template-literal-classname": eslint.Rule.RuleModule;
|
|
6
6
|
"no-kysely-interactive-transaction": eslint.Rule.RuleModule;
|
|
7
7
|
"no-module-internal-import": eslint.Rule.RuleModule;
|
|
8
|
+
"no-server-import-in-conventional-entry": eslint.Rule.RuleModule;
|
|
9
|
+
"rail-marker-congruent": eslint.Rule.RuleModule;
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
declare const configs: Record<string, Linter.Config>;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ declare const rules: {
|
|
|
5
5
|
"no-template-literal-classname": eslint.Rule.RuleModule;
|
|
6
6
|
"no-kysely-interactive-transaction": eslint.Rule.RuleModule;
|
|
7
7
|
"no-module-internal-import": eslint.Rule.RuleModule;
|
|
8
|
+
"no-server-import-in-conventional-entry": eslint.Rule.RuleModule;
|
|
9
|
+
"rail-marker-congruent": eslint.Rule.RuleModule;
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
declare const configs: Record<string, Linter.Config>;
|
package/dist/index.js
CHANGED
|
@@ -101,8 +101,13 @@ function findSrcRoot(filename) {
|
|
|
101
101
|
for (let i = 0; i < parts.length; i++) {
|
|
102
102
|
if (parts[i] === "src") lastSrcIdx = i;
|
|
103
103
|
}
|
|
104
|
-
if (lastSrcIdx
|
|
105
|
-
|
|
104
|
+
if (lastSrcIdx !== -1) return parts.slice(0, lastSrcIdx + 1).join("/");
|
|
105
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
106
|
+
if (parts[i] === "apps" && parts[i + 1] === "web") {
|
|
107
|
+
return parts.slice(0, i + 2).concat("src").join("/");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
106
111
|
}
|
|
107
112
|
function normalizePosixPath(raw) {
|
|
108
113
|
const absolute = raw.startsWith("/");
|
|
@@ -155,6 +160,99 @@ function isPublicSurface(resolvedPath, srcRoot, moduleName) {
|
|
|
155
160
|
if (resolvedPath === `${base}/index.tsx`) return true;
|
|
156
161
|
return false;
|
|
157
162
|
}
|
|
163
|
+
function isModuleRoutesEntry(resolvedPath, srcRoot, moduleName) {
|
|
164
|
+
const prefix = `${srcRoot}/modules/${moduleName}/routes/`;
|
|
165
|
+
return resolvedPath === `${srcRoot}/modules/${moduleName}/routes` || resolvedPath.startsWith(prefix);
|
|
166
|
+
}
|
|
167
|
+
var RAIL_MARKER = "@stardeck-module-rail-generated";
|
|
168
|
+
var I18N_GEN_MARKER = `// ${RAIL_MARKER} scope=i18n`;
|
|
169
|
+
var LOCALE_BASENAME_REGEX = /^[a-z]{2,3}(?:-[A-Za-z0-9]+)*$/;
|
|
170
|
+
var MAX_LOCALE_BASENAME_LENGTH = 35;
|
|
171
|
+
function isRailGeneratedRouteStub(filename, sourceText) {
|
|
172
|
+
const posix = toPosix(filename);
|
|
173
|
+
if (!/\/src\/app\/.+\/page\.tsx$/.test(posix) && !/\/src\/app\/page\.tsx$/.test(posix)) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
const firstLine = sourceText.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
177
|
+
return firstLine.startsWith(`// ${RAIL_MARKER} `) && firstLine.includes("scope=route ");
|
|
178
|
+
}
|
|
179
|
+
function isRailGeneratedCompositionImporter(filename, sourceText) {
|
|
180
|
+
const posix = toPosix(filename);
|
|
181
|
+
if (!/\/src\/(?:modules\.gen|module-contributions\.gen|module-i18n\.gen|module-init\.server\.gen)\.ts$/.test(
|
|
182
|
+
posix
|
|
183
|
+
)) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
const firstLine = sourceText.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
187
|
+
if (!firstLine.startsWith(`// ${RAIL_MARKER} `)) return false;
|
|
188
|
+
return firstLine.includes("scope=contributions") || firstLine.includes("scope=i18n") || firstLine.includes("scope=init") || firstLine.includes("scope=registry");
|
|
189
|
+
}
|
|
190
|
+
function isConventionalCompositionEntry(resolvedPath, srcRoot, moduleName) {
|
|
191
|
+
const base = `${srcRoot}/modules/${moduleName}`;
|
|
192
|
+
const allowedExact = /* @__PURE__ */ new Set([
|
|
193
|
+
`${base}/contributions`,
|
|
194
|
+
`${base}/contributions.ts`,
|
|
195
|
+
`${base}/slots`,
|
|
196
|
+
`${base}/slots.ts`,
|
|
197
|
+
`${base}/i18n`,
|
|
198
|
+
`${base}/i18n/index`,
|
|
199
|
+
`${base}/i18n/index.ts`
|
|
200
|
+
]);
|
|
201
|
+
if (allowedExact.has(resolvedPath)) return true;
|
|
202
|
+
const enhMatch = resolvedPath.match(
|
|
203
|
+
new RegExp(
|
|
204
|
+
`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/enhancements/([^/]+)/(contributions|initialize\\.server)(?:\\.ts)?$`
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
if (enhMatch) return true;
|
|
208
|
+
const enhI18n = resolvedPath.match(
|
|
209
|
+
new RegExp(
|
|
210
|
+
`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/enhancements/([^/]+)/i18n(?:/index(?:\\.ts)?)?$`
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
return Boolean(enhI18n);
|
|
214
|
+
}
|
|
215
|
+
function isRailGeneratedI18nJsonImporter(filename, sourceText) {
|
|
216
|
+
const posix = toPosix(filename);
|
|
217
|
+
if (!/\/src\/module-i18n\.gen\.ts$/.test(posix)) return false;
|
|
218
|
+
const firstLine = sourceText.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
219
|
+
return firstLine === I18N_GEN_MARKER;
|
|
220
|
+
}
|
|
221
|
+
function localeBasenameFromI18nJsonPath(resolvedPath, srcRoot, moduleName) {
|
|
222
|
+
const base = `${srcRoot}/modules/${moduleName}`;
|
|
223
|
+
const escaped = base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
224
|
+
const rootMatch = new RegExp(`^${escaped}/i18n/([^/]+)\\.json$`).exec(resolvedPath);
|
|
225
|
+
if (rootMatch) return rootMatch[1] ?? null;
|
|
226
|
+
const sliceMatch = new RegExp(`^${escaped}/enhancements/[^/]+/i18n/([^/]+)\\.json$`).exec(
|
|
227
|
+
resolvedPath
|
|
228
|
+
);
|
|
229
|
+
return sliceMatch ? sliceMatch[1] ?? null : null;
|
|
230
|
+
}
|
|
231
|
+
function isValidLocaleBasename(basename) {
|
|
232
|
+
return basename.length > 0 && basename.length <= MAX_LOCALE_BASENAME_LENGTH && LOCALE_BASENAME_REGEX.test(basename);
|
|
233
|
+
}
|
|
234
|
+
function isConventionalI18nJsonEntry(resolvedPath, srcRoot, moduleName) {
|
|
235
|
+
const basename = localeBasenameFromI18nJsonPath(resolvedPath, srcRoot, moduleName);
|
|
236
|
+
return basename != null && isValidLocaleBasename(basename);
|
|
237
|
+
}
|
|
238
|
+
function isRailGeneratedEndpointStub(filename, sourceText) {
|
|
239
|
+
const posix = toPosix(filename);
|
|
240
|
+
if (!/\/src\/app\/api\/.+\/route\.ts$/.test(posix)) return false;
|
|
241
|
+
const firstLine = sourceText.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
242
|
+
return firstLine.startsWith(`// ${RAIL_MARKER} `) && (firstLine.includes("scope=root") || firstLine.includes("scope=enhancement:"));
|
|
243
|
+
}
|
|
244
|
+
function isEndpointHandlerEntry(resolvedPath, srcRoot, moduleName) {
|
|
245
|
+
const base = `${srcRoot}/modules/${moduleName}`;
|
|
246
|
+
if (resolvedPath === `${base}/server` || resolvedPath === `${base}/server/index` || resolvedPath === `${base}/server/index.ts`) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
const enh = resolvedPath.match(
|
|
250
|
+
new RegExp(
|
|
251
|
+
`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/enhancements/([^/]+)(?:/index(?:\\.ts)?)?$`
|
|
252
|
+
)
|
|
253
|
+
);
|
|
254
|
+
return Boolean(enh);
|
|
255
|
+
}
|
|
158
256
|
var rule3 = {
|
|
159
257
|
meta: {
|
|
160
258
|
type: "problem",
|
|
@@ -178,6 +276,11 @@ var rule3 = {
|
|
|
178
276
|
}
|
|
179
277
|
const root = srcRoot;
|
|
180
278
|
const importerModule = getModuleName(toPosix(filename), root);
|
|
279
|
+
const sourceText = context.sourceCode.getText();
|
|
280
|
+
const railRouteStub = isRailGeneratedRouteStub(filename, sourceText);
|
|
281
|
+
const railCompositionImporter = isRailGeneratedCompositionImporter(filename, sourceText);
|
|
282
|
+
const railI18nJsonImporter = isRailGeneratedI18nJsonImporter(filename, sourceText);
|
|
283
|
+
const railEndpointStub = isRailGeneratedEndpointStub(filename, sourceText);
|
|
181
284
|
function check(node, sourceNode) {
|
|
182
285
|
if (!sourceNode || sourceNode.type !== "Literal") return;
|
|
183
286
|
const value = sourceNode.value;
|
|
@@ -188,6 +291,14 @@ var rule3 = {
|
|
|
188
291
|
if (!targetModule) return;
|
|
189
292
|
if (isPublicSurface(resolved, root, targetModule)) return;
|
|
190
293
|
if (importerModule === targetModule) return;
|
|
294
|
+
if (railRouteStub && isModuleRoutesEntry(resolved, root, targetModule)) return;
|
|
295
|
+
if (railCompositionImporter && isConventionalCompositionEntry(resolved, root, targetModule)) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (railI18nJsonImporter && isConventionalI18nJsonEntry(resolved, root, targetModule)) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (railEndpointStub && isEndpointHandlerEntry(resolved, root, targetModule)) return;
|
|
191
302
|
context.report({
|
|
192
303
|
node,
|
|
193
304
|
messageId: "noInternalImport",
|
|
@@ -207,17 +318,361 @@ var rule3 = {
|
|
|
207
318
|
},
|
|
208
319
|
ExportAllDeclaration(node) {
|
|
209
320
|
check(node, node.source);
|
|
321
|
+
},
|
|
322
|
+
// Literal CommonJS `require("...")` — same isolation rule as ESM imports.
|
|
323
|
+
CallExpression(node) {
|
|
324
|
+
const call = node;
|
|
325
|
+
if (call.callee?.type !== "Identifier" || call.callee.name !== "require") return;
|
|
326
|
+
const arg0 = call.arguments?.[0];
|
|
327
|
+
if (!arg0 || arg0.type !== "Literal" || typeof arg0.value !== "string") return;
|
|
328
|
+
check(node, arg0);
|
|
329
|
+
},
|
|
330
|
+
// TypeScript `import x = require("...")` (TS-ESLint AST).
|
|
331
|
+
TSImportEqualsDeclaration(node) {
|
|
332
|
+
const decl = node;
|
|
333
|
+
const ref = decl.moduleReference;
|
|
334
|
+
if (!ref || ref.type !== "TSExternalModuleReference") return;
|
|
335
|
+
const expression = ref.expression;
|
|
336
|
+
if (!expression || expression.type !== "Literal" || typeof expression.value !== "string") {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
check(node, expression);
|
|
210
340
|
}
|
|
211
341
|
};
|
|
212
342
|
}
|
|
213
343
|
};
|
|
214
344
|
var no_module_internal_import_default = rule3;
|
|
215
345
|
|
|
346
|
+
// src/rules/no-server-import-in-conventional-entry.ts
|
|
347
|
+
import path2 from "path";
|
|
348
|
+
function toPosix2(filePath) {
|
|
349
|
+
return filePath.split(path2.sep).join("/");
|
|
350
|
+
}
|
|
351
|
+
function isClientSafeConventionalEntry(filename) {
|
|
352
|
+
const posix = toPosix2(filename);
|
|
353
|
+
return /\/src\/modules\/[^/]+\/(?:contributions|slots)\.ts$/.test(posix) || /\/src\/modules\/[^/]+\/enhancements\/[^/]+\/contributions\.ts$/.test(posix);
|
|
354
|
+
}
|
|
355
|
+
var NODE_BUILTIN_MODULE_NAMES = /* @__PURE__ */ new Set([
|
|
356
|
+
"assert",
|
|
357
|
+
"async_hooks",
|
|
358
|
+
"buffer",
|
|
359
|
+
"child_process",
|
|
360
|
+
"cluster",
|
|
361
|
+
"console",
|
|
362
|
+
"constants",
|
|
363
|
+
"crypto",
|
|
364
|
+
"dgram",
|
|
365
|
+
"diagnostics_channel",
|
|
366
|
+
"dns",
|
|
367
|
+
"domain",
|
|
368
|
+
"events",
|
|
369
|
+
"fs",
|
|
370
|
+
"http",
|
|
371
|
+
"http2",
|
|
372
|
+
"https",
|
|
373
|
+
"inspector",
|
|
374
|
+
"module",
|
|
375
|
+
"net",
|
|
376
|
+
"os",
|
|
377
|
+
"path",
|
|
378
|
+
"perf_hooks",
|
|
379
|
+
"process",
|
|
380
|
+
"punycode",
|
|
381
|
+
"querystring",
|
|
382
|
+
"readline",
|
|
383
|
+
"repl",
|
|
384
|
+
"stream",
|
|
385
|
+
"string_decoder",
|
|
386
|
+
"sys",
|
|
387
|
+
"timers",
|
|
388
|
+
"tls",
|
|
389
|
+
"trace_events",
|
|
390
|
+
"tty",
|
|
391
|
+
"url",
|
|
392
|
+
"util",
|
|
393
|
+
"v8",
|
|
394
|
+
"vm",
|
|
395
|
+
"wasi",
|
|
396
|
+
"worker_threads",
|
|
397
|
+
"zlib"
|
|
398
|
+
]);
|
|
399
|
+
function isNodeBuiltinImportSpecifier(specifier) {
|
|
400
|
+
const withoutNodePrefix = specifier.startsWith("node:") ? specifier.slice("node:".length) : specifier;
|
|
401
|
+
if (withoutNodePrefix.startsWith("@")) return false;
|
|
402
|
+
const firstSegment = withoutNodePrefix.split("/")[0] ?? withoutNodePrefix;
|
|
403
|
+
return specifier.startsWith("node:") || NODE_BUILTIN_MODULE_NAMES.has(firstSegment);
|
|
404
|
+
}
|
|
405
|
+
function classifyForbiddenSpecifier(specifier) {
|
|
406
|
+
if (specifier === "server-only") {
|
|
407
|
+
return {
|
|
408
|
+
reason: "server-only-package",
|
|
409
|
+
message: `import of "server-only" package "${specifier}" is forbidden in a client-safe conventional entry`
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
if (isNodeBuiltinImportSpecifier(specifier)) {
|
|
413
|
+
return {
|
|
414
|
+
reason: "node-builtin",
|
|
415
|
+
message: `import of Node builtin "${specifier}" is forbidden in a client-safe conventional entry`
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
const pathPart = specifier.split(/[?#]/, 1)[0] ?? specifier;
|
|
419
|
+
const segments = pathPart.split("/").filter((s) => s.length > 0 && s !== ".");
|
|
420
|
+
if (/\.server(?:\.[cm]?[tj]sx?)?$/.test(pathPart)) {
|
|
421
|
+
return {
|
|
422
|
+
reason: "dot-server-file",
|
|
423
|
+
message: `import of a ".server" file "${specifier}" is forbidden in a client-safe conventional entry`
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
if (segments.some((seg) => seg === "server")) {
|
|
427
|
+
return {
|
|
428
|
+
reason: "server-path-segment",
|
|
429
|
+
message: `import reaching a "/server" module entry "${specifier}" is forbidden in a client-safe conventional entry`
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
const enhIdx = segments.lastIndexOf("enhancements");
|
|
433
|
+
if (enhIdx !== -1) {
|
|
434
|
+
const rest = segments.slice(enhIdx + 1);
|
|
435
|
+
const isRootBarrel = rest.length === 1 || rest.length === 2 && (rest[1] === "index" || rest[1] === "index.ts");
|
|
436
|
+
if (isRootBarrel) {
|
|
437
|
+
return {
|
|
438
|
+
reason: "enhancement-root-entry",
|
|
439
|
+
message: `import of enhancement root entry "${specifier}" is forbidden in a client-safe conventional entry (may carry server initialization)`
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
var rule4 = {
|
|
446
|
+
meta: {
|
|
447
|
+
type: "problem",
|
|
448
|
+
docs: {
|
|
449
|
+
description: "Disallow direct server-only / node builtin / .server / /server / enhancement-root imports inside contributions.ts and slots.ts, which are bundled into client-reachable composition artifacts",
|
|
450
|
+
recommended: true
|
|
451
|
+
},
|
|
452
|
+
messages: {
|
|
453
|
+
forbiddenServerImport: "{{message}}"
|
|
454
|
+
},
|
|
455
|
+
schema: []
|
|
456
|
+
},
|
|
457
|
+
create(context) {
|
|
458
|
+
const filename = context.filename;
|
|
459
|
+
if (!filename || filename === "<input>" || filename === "<text>") {
|
|
460
|
+
return {};
|
|
461
|
+
}
|
|
462
|
+
if (!isClientSafeConventionalEntry(filename)) {
|
|
463
|
+
return {};
|
|
464
|
+
}
|
|
465
|
+
function check(node, sourceNode) {
|
|
466
|
+
if (!sourceNode || sourceNode.type !== "Literal") return;
|
|
467
|
+
const value = sourceNode.value;
|
|
468
|
+
if (typeof value !== "string") return;
|
|
469
|
+
const forbidden = classifyForbiddenSpecifier(value);
|
|
470
|
+
if (!forbidden) return;
|
|
471
|
+
context.report({
|
|
472
|
+
node,
|
|
473
|
+
messageId: "forbiddenServerImport",
|
|
474
|
+
data: { message: forbidden.message }
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
return {
|
|
478
|
+
ImportDeclaration(node) {
|
|
479
|
+
check(node, node.source);
|
|
480
|
+
},
|
|
481
|
+
ImportExpression(node) {
|
|
482
|
+
const src = node.source;
|
|
483
|
+
check(node, src);
|
|
484
|
+
},
|
|
485
|
+
ExportNamedDeclaration(node) {
|
|
486
|
+
check(node, node.source);
|
|
487
|
+
},
|
|
488
|
+
ExportAllDeclaration(node) {
|
|
489
|
+
check(node, node.source);
|
|
490
|
+
},
|
|
491
|
+
// Literal CommonJS `require("...")` — same client-bundle risk as ESM import.
|
|
492
|
+
CallExpression(node) {
|
|
493
|
+
const call = node;
|
|
494
|
+
if (call.callee?.type !== "Identifier" || call.callee.name !== "require") return;
|
|
495
|
+
const arg0 = call.arguments?.[0];
|
|
496
|
+
if (!arg0 || arg0.type !== "Literal" || typeof arg0.value !== "string") return;
|
|
497
|
+
const forbidden = classifyForbiddenSpecifier(arg0.value);
|
|
498
|
+
if (!forbidden) return;
|
|
499
|
+
context.report({
|
|
500
|
+
node,
|
|
501
|
+
messageId: "forbiddenServerImport",
|
|
502
|
+
data: { message: forbidden.message }
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
// TypeScript `import x = require("...")` (TS-ESLint AST).
|
|
506
|
+
TSImportEqualsDeclaration(node) {
|
|
507
|
+
const decl = node;
|
|
508
|
+
const ref = decl.moduleReference;
|
|
509
|
+
if (!ref || ref.type !== "TSExternalModuleReference") return;
|
|
510
|
+
const expr = ref.expression;
|
|
511
|
+
if (!expr || expr.type !== "Literal" || typeof expr.value !== "string") return;
|
|
512
|
+
const forbidden = classifyForbiddenSpecifier(expr.value);
|
|
513
|
+
if (!forbidden) return;
|
|
514
|
+
context.report({
|
|
515
|
+
node,
|
|
516
|
+
messageId: "forbiddenServerImport",
|
|
517
|
+
data: { message: forbidden.message }
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
var no_server_import_in_conventional_entry_default = rule4;
|
|
524
|
+
|
|
525
|
+
// src/rules/rail-marker-congruent.ts
|
|
526
|
+
import path3 from "path";
|
|
527
|
+
var MARKER = "@stardeck-module-rail-generated";
|
|
528
|
+
var MARKER_RE = new RegExp(
|
|
529
|
+
`^//\\s*${MARKER}\\s+(?:owner=([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\\s+)?scope=(\\S+)(?:\\s+path=(.+))?$`
|
|
530
|
+
);
|
|
531
|
+
var OWNERLESS_SCOPES = {
|
|
532
|
+
registry: "registry",
|
|
533
|
+
contributions: "contributions",
|
|
534
|
+
datastores: "datastores",
|
|
535
|
+
i18n: "i18n",
|
|
536
|
+
init: "init"
|
|
537
|
+
};
|
|
538
|
+
var GEN_FILE_KINDS = {
|
|
539
|
+
"modules.gen.ts": "registry",
|
|
540
|
+
"module-contributions.gen.ts": "contributions",
|
|
541
|
+
"module-datastores.gen.ts": "datastores",
|
|
542
|
+
"module-i18n.gen.ts": "i18n",
|
|
543
|
+
"module-init.server.gen.ts": "init"
|
|
544
|
+
};
|
|
545
|
+
var METHODS = "GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS";
|
|
546
|
+
var OWNER = "[a-z][a-z0-9]*(?:-[a-z0-9]+)*";
|
|
547
|
+
function isLegacyApiAdapterBody(source, owner) {
|
|
548
|
+
const lines = source.replace(/\r\n/g, "\n").split("\n").slice(1).map((line) => line.trim()).filter(Boolean);
|
|
549
|
+
const importMatch = lines[0]?.match(
|
|
550
|
+
new RegExp(
|
|
551
|
+
`^import \\{ (endpointHandlers|production(?:[A-Z][A-Za-z0-9]*)?Handlers) \\} from "(@/modules/${owner}/server|@/modules/${owner}/enhancements/${OWNER}|@/lib/${owner}-wiring)";$`
|
|
552
|
+
)
|
|
553
|
+
);
|
|
554
|
+
if (!importMatch) return false;
|
|
555
|
+
const binding = importMatch[1];
|
|
556
|
+
const exports = lines.slice(1);
|
|
557
|
+
return exports.length > 0 && exports.every(
|
|
558
|
+
(line) => new RegExp(`^export const (${METHODS}) = ${binding}\\.\\1_[A-Za-z0-9_]+;$`).test(line)
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
function isLegacyRouteAdapterBody(source, routePath) {
|
|
562
|
+
return new RegExp(
|
|
563
|
+
`^// ${MARKER} scope=routes
|
|
564
|
+
/\\*\\* DO NOT EDIT \u2014 owned by the module install rail\\. \\*/
|
|
565
|
+
export \\{ default \\} from "@/modules/${OWNER}/routes/${routePath.replace(/[.*+?^$()[\]{}|]/g, "\\$&")}/page";
|
|
566
|
+
?$`
|
|
567
|
+
).test(source.replace(/\r\n/g, "\n"));
|
|
568
|
+
}
|
|
569
|
+
function parseMarker(source) {
|
|
570
|
+
const firstLine = source.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
571
|
+
const match = firstLine.match(MARKER_RE);
|
|
572
|
+
if (!match) return null;
|
|
573
|
+
const [, owner, scope, routePath] = match;
|
|
574
|
+
const ownerless = OWNERLESS_SCOPES[scope];
|
|
575
|
+
if (ownerless) return owner ? null : { kind: ownerless };
|
|
576
|
+
if (scope === "routes") return owner ? null : { kind: "route", legacyRoute: true };
|
|
577
|
+
if (!owner) return null;
|
|
578
|
+
if (scope === "route") {
|
|
579
|
+
const trimmed = routePath?.trim();
|
|
580
|
+
return trimmed ? { kind: "route", routePath: trimmed, owner } : null;
|
|
581
|
+
}
|
|
582
|
+
if (scope === "root" || scope.startsWith("enhancement:")) return { kind: "endpoint", owner };
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
function shapeForPath(filename) {
|
|
586
|
+
const posix = filename.split(path3.sep).join("/");
|
|
587
|
+
const gen = posix.match(/\/src\/([^/]+\.gen\.ts)$/);
|
|
588
|
+
if (gen) {
|
|
589
|
+
const kind = GEN_FILE_KINDS[gen[1]];
|
|
590
|
+
return kind ? { kind } : null;
|
|
591
|
+
}
|
|
592
|
+
const idx = posix.lastIndexOf("/src/app/");
|
|
593
|
+
if (idx < 0) return null;
|
|
594
|
+
const rest = posix.slice(idx + "/src/app/".length);
|
|
595
|
+
if (rest.startsWith("api/")) {
|
|
596
|
+
const m2 = rest.match(/^(.+)\/route\.ts$/);
|
|
597
|
+
return m2 ? { kind: "endpoint", routePath: m2[1] } : null;
|
|
598
|
+
}
|
|
599
|
+
const m = rest.match(/^(?:(.*)\/)?page\.(?:tsx|ts|jsx|js)$/);
|
|
600
|
+
return m ? { kind: "route", routePath: m[1] ?? "" } : null;
|
|
601
|
+
}
|
|
602
|
+
var rule5 = {
|
|
603
|
+
meta: {
|
|
604
|
+
type: "problem",
|
|
605
|
+
docs: {
|
|
606
|
+
description: "Require a @stardeck-module-rail-generated marker to match the file's path shape, so Blueprint publish can reconcile the file",
|
|
607
|
+
recommended: true
|
|
608
|
+
},
|
|
609
|
+
messages: {
|
|
610
|
+
wrongKind: "Found a {{found}} rail marker on a path shaped for {{expected}} artifacts. Blueprint publish will refuse to reconcile a swapped marker. Delete the marker line if this file is hand-written, or restore the generated stub.",
|
|
611
|
+
missingMarker: "Generated file {{file}} has no @stardeck-module-rail-generated marker on line 1. Blueprint publish will refuse to overwrite it as unmanaged. Restore the marker line (or the whole generated file) rather than editing it by hand.",
|
|
612
|
+
legacyRouteBody: "Rail marker scope=routes is only valid with its original body: the DO NOT EDIT line and a single default re-export of this route's page from its Module. Blueprint publish treats anything else as unmanaged. Delete the marker line if this file is hand-written, or restore the generated stub.",
|
|
613
|
+
wrongRoutePath: 'Rail route marker claims path="{{claimed}}" but this file serves "{{actual}}". Blueprint publish will refuse to reconcile it. Delete the marker line if this file is hand-written, or restore the generated stub.'
|
|
614
|
+
},
|
|
615
|
+
schema: []
|
|
616
|
+
},
|
|
617
|
+
create(context) {
|
|
618
|
+
const filename = context.filename;
|
|
619
|
+
if (!filename || filename === "<input>" || filename === "<text>") return {};
|
|
620
|
+
const shape = shapeForPath(filename);
|
|
621
|
+
if (!shape) return {};
|
|
622
|
+
return {
|
|
623
|
+
Program(node) {
|
|
624
|
+
const marker = parseMarker(context.sourceCode.text);
|
|
625
|
+
const loc = { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } };
|
|
626
|
+
if (!marker) {
|
|
627
|
+
if (GEN_FILE_KINDS[path3.basename(filename)]) {
|
|
628
|
+
context.report({
|
|
629
|
+
node,
|
|
630
|
+
loc,
|
|
631
|
+
messageId: "missingMarker",
|
|
632
|
+
data: { file: path3.basename(filename) }
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
if (marker.kind !== shape.kind) {
|
|
638
|
+
if (shape.kind === "endpoint" && marker.kind === "route" && marker.routePath === shape.routePath && isLegacyApiAdapterBody(context.sourceCode.text, marker.owner)) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
context.report({
|
|
642
|
+
node,
|
|
643
|
+
loc,
|
|
644
|
+
messageId: "wrongKind",
|
|
645
|
+
data: { found: marker.kind, expected: shape.kind }
|
|
646
|
+
});
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
if (marker.legacyRoute) {
|
|
650
|
+
if (!isLegacyRouteAdapterBody(context.sourceCode.text, shape.routePath ?? "")) {
|
|
651
|
+
context.report({ node, loc, messageId: "legacyRouteBody" });
|
|
652
|
+
}
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (marker.kind === "route" && marker.routePath !== shape.routePath) {
|
|
656
|
+
context.report({
|
|
657
|
+
node,
|
|
658
|
+
loc,
|
|
659
|
+
messageId: "wrongRoutePath",
|
|
660
|
+
data: { claimed: marker.routePath ?? "", actual: shape.routePath ?? "" }
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
var rail_marker_congruent_default = rule5;
|
|
668
|
+
|
|
216
669
|
// src/rules/index.ts
|
|
217
670
|
var rules = {
|
|
218
671
|
"no-template-literal-classname": no_template_literal_classname_default,
|
|
219
672
|
"no-kysely-interactive-transaction": no_kysely_interactive_transaction_default,
|
|
220
|
-
"no-module-internal-import": no_module_internal_import_default
|
|
673
|
+
"no-module-internal-import": no_module_internal_import_default,
|
|
674
|
+
"no-server-import-in-conventional-entry": no_server_import_in_conventional_entry_default,
|
|
675
|
+
"rail-marker-congruent": rail_marker_congruent_default
|
|
221
676
|
};
|
|
222
677
|
|
|
223
678
|
// src/configs/recommended.ts
|
|
@@ -231,7 +686,9 @@ var recommended = {
|
|
|
231
686
|
rules: {
|
|
232
687
|
[`${pluginName}/no-template-literal-classname`]: "error",
|
|
233
688
|
[`${pluginName}/no-kysely-interactive-transaction`]: "error",
|
|
234
|
-
[`${pluginName}/no-module-internal-import`]: "error"
|
|
689
|
+
[`${pluginName}/no-module-internal-import`]: "error",
|
|
690
|
+
[`${pluginName}/no-server-import-in-conventional-entry`]: "error",
|
|
691
|
+
[`${pluginName}/rail-marker-congruent`]: "error"
|
|
235
692
|
}
|
|
236
693
|
};
|
|
237
694
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stardeck-customer-apps/eslint-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Custom ESLint rules for Stardeck customer apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"SKILL.md"
|
|
15
16
|
],
|
|
16
17
|
"exports": {
|
|
17
18
|
".": {
|