@nifrajs/cli 5.9.0 → 5.10.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/CHANGELOG.md +57 -0
- package/dist/check-diagnostics.d.ts +1 -0
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +4 -0
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +1 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +8 -1
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +7 -2
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -8
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +1 -5
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +2 -21
- package/dist/command-catalog.js.map +1 -1
- package/dist/internal/source-facts.d.ts +30 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +127 -0
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/load.d.ts +2 -0
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +5 -0
- package/dist/load.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-tool-meta.d.ts.map +1 -1
- package/dist/mcp-tool-meta.js +0 -1
- package/dist/mcp-tool-meta.js.map +1 -1
- package/dist/recipes/5.10.0.d.ts +12 -0
- package/dist/recipes/5.10.0.d.ts.map +1 -0
- package/dist/recipes/5.10.0.js +44 -0
- package/dist/recipes/5.10.0.js.map +1 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +2 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +3 -0
- package/dist/review.js.map +1 -1
- package/dist/rules/codes.d.ts +3 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +3 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/explanations.d.ts.map +1 -1
- package/dist/rules/explanations.js +15 -0
- package/dist/rules/explanations.js.map +1 -1
- package/dist/rules/internal-links.d.ts +5 -0
- package/dist/rules/internal-links.d.ts.map +1 -0
- package/dist/rules/internal-links.js +418 -0
- package/dist/rules/internal-links.js.map +1 -0
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +20 -0
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/server-fn-namespace.d.ts +8 -0
- package/dist/rules/server-fn-namespace.d.ts.map +1 -0
- package/dist/rules/server-fn-namespace.js +43 -0
- package/dist/rules/server-fn-namespace.js.map +1 -0
- package/dist/rules/source-scan.d.ts +29 -0
- package/dist/rules/source-scan.d.ts.map +1 -0
- package/dist/rules/source-scan.js +38 -0
- package/dist/rules/source-scan.js.map +1 -0
- package/dist/rules/text-slot-boolean.d.ts.map +1 -1
- package/dist/rules/text-slot-boolean.js +21 -43
- package/dist/rules/text-slot-boolean.js.map +1 -1
- package/dist/source-rewrites.d.ts.map +1 -1
- package/dist/source-rewrites.js +118 -3
- package/dist/source-rewrites.js.map +1 -1
- package/dist/typecheck-coverage.d.ts +9 -0
- package/dist/typecheck-coverage.d.ts.map +1 -1
- package/dist/typecheck-coverage.js +16 -0
- package/dist/typecheck-coverage.js.map +1 -1
- package/docs/examples.json +19 -7
- package/docs/llms-full.txt +555 -200
- package/docs/types.json +560 -115
- package/package.json +11 -11
- package/src/check-diagnostics.ts +5 -0
- package/src/check-scan.ts +9 -1
- package/src/check.ts +15 -3
- package/src/cli.ts +16 -8
- package/src/command-catalog.ts +2 -26
- package/src/internal/source-facts.ts +155 -0
- package/src/load.ts +9 -0
- package/src/mcp-http.ts +1 -1
- package/src/mcp-tool-meta.ts +0 -1
- package/src/recipes/5.10.0.ts +45 -0
- package/src/recipes/index.ts +2 -0
- package/src/review.ts +3 -0
- package/src/rules/codes.ts +3 -0
- package/src/rules/explanations.ts +15 -0
- package/src/rules/internal-links.ts +490 -0
- package/src/rules/legacy.ts +21 -0
- package/src/rules/server-fn-namespace.ts +47 -0
- package/src/rules/source-scan.ts +66 -0
- package/src/rules/text-slot-boolean.ts +26 -42
- package/src/source-rewrites.ts +133 -4
- package/src/typecheck-coverage.ts +23 -0
- package/dist/sync-routes.d.ts +0 -29
- package/dist/sync-routes.d.ts.map +0 -1
- package/dist/sync-routes.js +0 -56
- package/dist/sync-routes.js.map +0 -1
- package/src/sync-routes.ts +0 -70
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { Glob } from "bun";
|
|
4
|
+
import { CONFIG_FILE, FRAMEWORK_FILE } from "../app-files.js";
|
|
5
|
+
import { IGNORED, stripComments } from "../check-scan.js";
|
|
6
|
+
import { diagnostic } from "../diagnostics.js";
|
|
7
|
+
import { codeUnitOrder } from "../internal/code-unit-order.js";
|
|
8
|
+
import { toPosix } from "../internal/posix-path.js";
|
|
9
|
+
import { ANCHOR_HOLE } from "../internal/source-facts.js";
|
|
10
|
+
import { buildRouteTable } from "../introspect.js";
|
|
11
|
+
import { commentBlockExpectation } from "./comment-markers.js";
|
|
12
|
+
import { readStaticApiPrefix } from "./pages.js";
|
|
13
|
+
import { scanSources } from "./source-scan.js";
|
|
14
|
+
/**
|
|
15
|
+
* NF-C057 and NF-C058 - an `<a href="/path">` written as a string. `href()` checks a link against the
|
|
16
|
+
* app's routes, so a renamed or removed page is a compile error; a path string is invisible to the types.
|
|
17
|
+
* The two codes split what the route table can tell apart, so each takes its own severity:
|
|
18
|
+
*
|
|
19
|
+
* - NF-C057 (warn): the path matches no page, no backend route and no file: the link is a 404.
|
|
20
|
+
* - NF-C058 (info): the path is a page of the app, so it works today but nothing keeps it working.
|
|
21
|
+
*
|
|
22
|
+
* A template literal (`/users/${id}`) is judged by its shape only, and never reported as dead: the
|
|
23
|
+
* route it builds may live outside the file routes.
|
|
24
|
+
*/
|
|
25
|
+
const TEST_DIR = /(?:^|\/)(?:tests?|__tests__)\//;
|
|
26
|
+
const FILE_EXTENSION = /\.[A-Za-z0-9]{1,8}$/;
|
|
27
|
+
// One attribute of a tag, matched where the previous one ended (sticky), so a tag is read in one pass:
|
|
28
|
+
// `href="/x"`, `href='/x'`, `href={"/x"}` or `` href={`/x`} `` (Svelte), and Vue's `:href="'/x'"`. Any
|
|
29
|
+
// other `{...}` value is an expression and names no path.
|
|
30
|
+
const ATTRIBUTE = /\s+([^\s=>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`)\s*\}|\{[^}]*\}))?/y;
|
|
31
|
+
const BOUND_LITERAL = /^\s*(?:'([^']*)'|"([^"]*)"|`([^`$]*)`)\s*$/;
|
|
32
|
+
const cache = new WeakMap();
|
|
33
|
+
function distance(a, b) {
|
|
34
|
+
let row = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
35
|
+
for (let i = 1; i <= a.length; i++) {
|
|
36
|
+
const next = [i];
|
|
37
|
+
for (let j = 1; j <= b.length; j++) {
|
|
38
|
+
next[j] = Math.min((row[j] ?? 0) + 1, (next[j - 1] ?? 0) + 1, (row[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
39
|
+
}
|
|
40
|
+
row = next;
|
|
41
|
+
}
|
|
42
|
+
return row[b.length] ?? 0;
|
|
43
|
+
}
|
|
44
|
+
/** Read only literal mount exports, never import/evaluate the app's config. An unreadable field
|
|
45
|
+
* leaves the dead-link verdict open, just like an unreadable backend registration. */
|
|
46
|
+
function backendMount(ctx) {
|
|
47
|
+
let prefix;
|
|
48
|
+
let strip = false;
|
|
49
|
+
let prefixUnknown = false;
|
|
50
|
+
let stripUnknown = false;
|
|
51
|
+
// nifra.config.ts overrides individual fields inherited from backend/framework.ts.
|
|
52
|
+
for (const file of [FRAMEWORK_FILE, CONFIG_FILE]) {
|
|
53
|
+
const path = join(ctx.root, file);
|
|
54
|
+
if (!existsSync(path))
|
|
55
|
+
continue;
|
|
56
|
+
const source = stripComments(readFileSync(path, "utf8"));
|
|
57
|
+
const read = readStaticApiPrefix(source);
|
|
58
|
+
if (read.kind !== "default") {
|
|
59
|
+
prefixUnknown = read.kind === "unreadable";
|
|
60
|
+
if (read.kind === "literal")
|
|
61
|
+
prefix = read.value;
|
|
62
|
+
}
|
|
63
|
+
if (/\bapiStrip\b/.test(source)) {
|
|
64
|
+
const literal = /\bexport\s+const\s+apiStrip\s*(?::\s*boolean\s*)?=\s*(true|false)\s*(?:as\s+const\s*)?(?:;|\r?\n|$)/.exec(source);
|
|
65
|
+
stripUnknown = literal === null;
|
|
66
|
+
if (literal !== null)
|
|
67
|
+
strip = literal[1] === "true";
|
|
68
|
+
}
|
|
69
|
+
// A star re-export may supply either field; it cannot prove an absent/default mount.
|
|
70
|
+
if (/\bexport\s*\*/.test(source)) {
|
|
71
|
+
prefixUnknown = true;
|
|
72
|
+
stripUnknown = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return prefixUnknown || stripUnknown ? undefined : { prefix, strip };
|
|
76
|
+
}
|
|
77
|
+
function pageRoutes(ctx) {
|
|
78
|
+
let loaded = cache.get(ctx);
|
|
79
|
+
if (loaded === undefined) {
|
|
80
|
+
loaded = loadPageRoutes(ctx);
|
|
81
|
+
cache.set(ctx, loaded);
|
|
82
|
+
}
|
|
83
|
+
return loaded;
|
|
84
|
+
}
|
|
85
|
+
async function loadPageRoutes(ctx) {
|
|
86
|
+
// The pages come from the file system, not the scanned sources: a `.vue`, `.svelte` or `.mdx` page is
|
|
87
|
+
// not in the source index, and a missed page would turn its links into false 404s.
|
|
88
|
+
const routesDir = join(ctx.root, "routes");
|
|
89
|
+
if (!existsSync(routesDir))
|
|
90
|
+
return undefined;
|
|
91
|
+
const { discoverRoutes } = await import("@nifrajs/web/fs");
|
|
92
|
+
const { compileRoutePattern, matchRoutePattern, sortRoutesBySpecificity } = await import("@nifrajs/core/pattern");
|
|
93
|
+
let patterns;
|
|
94
|
+
try {
|
|
95
|
+
patterns = discoverRoutes(routesDir).routes.map((route) => route.pattern);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
if (patterns.length === 0)
|
|
101
|
+
return undefined;
|
|
102
|
+
// `sortRoutesBySpecificity` reads the compiled pattern from `pattern`, and carries the rest along.
|
|
103
|
+
const compile = (route) => {
|
|
104
|
+
try {
|
|
105
|
+
return [{ route, pattern: compileRoutePattern(route) }];
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const pageEntries = sortRoutesBySpecificity(patterns.flatMap(compile));
|
|
112
|
+
const mount = backendMount(ctx);
|
|
113
|
+
const backendEntries = buildRouteTable({
|
|
114
|
+
pages: [],
|
|
115
|
+
api: ctx.project.routes,
|
|
116
|
+
apiPrefix: mount?.prefix ?? "",
|
|
117
|
+
apiStrip: mount?.strip ?? false,
|
|
118
|
+
})
|
|
119
|
+
// Without a configured mount, preserve the scan's allowance for independently served backends.
|
|
120
|
+
.filter((route) => mount?.prefix === undefined || route.autoMounted)
|
|
121
|
+
.flatMap((route) => compile(route.path));
|
|
122
|
+
// Code-unit order, so which of two equally close pages a diagnostic names does not depend on the
|
|
123
|
+
// directory order of the machine that ran the check.
|
|
124
|
+
const staticPatterns = patterns.filter((pattern) => !/[:*]/.test(pattern)).sort(codeUnitOrder);
|
|
125
|
+
return {
|
|
126
|
+
backendUnknown: mount === undefined || ctx.project.sourceFindings.routePaths.length > 0,
|
|
127
|
+
match(path) {
|
|
128
|
+
for (const entry of pageEntries) {
|
|
129
|
+
const found = matchRoutePattern(entry.pattern, path);
|
|
130
|
+
if (found.matched)
|
|
131
|
+
return {
|
|
132
|
+
pattern: entry.route,
|
|
133
|
+
params: new Map(Object.entries(found.params).map(([k, v]) => [k, String(v)])),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
},
|
|
138
|
+
servedElsewhere(path) {
|
|
139
|
+
if (backendEntries.some((entry) => matchRoutePattern(entry.pattern, path).matched))
|
|
140
|
+
return true;
|
|
141
|
+
if (FILE_EXTENSION.test(path) || path.startsWith("/_"))
|
|
142
|
+
return true;
|
|
143
|
+
try {
|
|
144
|
+
return existsSync(join(ctx.root, "public", decodeURI(path)));
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
nearest(path) {
|
|
151
|
+
let best;
|
|
152
|
+
for (const pattern of staticPatterns) {
|
|
153
|
+
const at = distance(path, pattern);
|
|
154
|
+
if (at <= 2 && (best === undefined || at < best.at))
|
|
155
|
+
best = { pattern, at };
|
|
156
|
+
}
|
|
157
|
+
return best?.pattern;
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const spell = (path) => path.replaceAll(ANCHOR_HOLE, `\${…}`);
|
|
162
|
+
/** Judge one anchor path (a hole stands for a `${...}`), or undefined when it is not this rule's business. */
|
|
163
|
+
function judge(routes, written) {
|
|
164
|
+
const cut = written.search(/[?#]/);
|
|
165
|
+
const path = cut < 0 ? written : written.slice(0, cut);
|
|
166
|
+
const rest = cut < 0 ? "" : written.slice(cut);
|
|
167
|
+
const dynamic = path.includes(ANCHOR_HOLE);
|
|
168
|
+
const found = routes.match(path);
|
|
169
|
+
const shown = spell(written);
|
|
170
|
+
if (found !== undefined) {
|
|
171
|
+
const hash = rest.includes("#") ? rest.slice(rest.indexOf("#") + 1) : undefined;
|
|
172
|
+
const query = rest.startsWith("?");
|
|
173
|
+
const entries = [...found.params];
|
|
174
|
+
const params = entries.length === 0
|
|
175
|
+
? ""
|
|
176
|
+
: `, params: { ${entries.map(([name, value]) => `${name}: ${dynamic ? "…" : JSON.stringify(value)}`).join(", ")} }`;
|
|
177
|
+
const call = `href({ to: ${JSON.stringify(found.pattern)}${params}${query ? ", search: { … }" : ""}${hash !== undefined && hash !== "" && !hash.includes(ANCHOR_HOLE) ? `, hash: ${JSON.stringify(hash)}` : ""} })`;
|
|
178
|
+
return {
|
|
179
|
+
kind: "unchecked",
|
|
180
|
+
shown,
|
|
181
|
+
message: `\`<a href="${shown}">\` writes a page's path by hand, so renaming or removing ${found.pattern} leaves it dead and nothing fails. Build it with \`${call}\` (\`href\` is exported by \`@nifrajs/web-<framework>/router\`), which checks the route and its params against the app.`,
|
|
182
|
+
evidence: [
|
|
183
|
+
`${shown} resolves to the page route ${found.pattern}`,
|
|
184
|
+
"a path built elsewhere, such as a CMS link, takes `rawHref(path)`",
|
|
185
|
+
],
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (dynamic || routes.backendUnknown || routes.servedElsewhere(path))
|
|
189
|
+
return undefined;
|
|
190
|
+
const near = routes.nearest(path);
|
|
191
|
+
return {
|
|
192
|
+
kind: "dead",
|
|
193
|
+
shown,
|
|
194
|
+
message: `\`<a href="${shown}">\` links to a path no page of this app serves, so following it is a 404.${near === undefined ? "" : ` Did you mean ${near}?`} Use \`href({ to })\` with a route of the app, which fails to compile for one that does not exist.`,
|
|
195
|
+
evidence: [
|
|
196
|
+
`${path} matches no page route, no backend route and no file in public/`,
|
|
197
|
+
"a path another server answers takes `rawHref(path)`",
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const adviceFor = (code, template) => template
|
|
202
|
+
? `a link kept as written, on purpose: \`<!-- nifra-expect ${code}: <reason> -->\` above the anchor`
|
|
203
|
+
: `a link kept as written, on purpose: \`// nifra-expect ${code}: <reason>\` above the attribute`;
|
|
204
|
+
function report(code, severity, file, line, verdict, note, template = false) {
|
|
205
|
+
return diagnostic({
|
|
206
|
+
code,
|
|
207
|
+
severity,
|
|
208
|
+
file,
|
|
209
|
+
line,
|
|
210
|
+
message: note === undefined ? verdict.message : `${verdict.message} ${note}`,
|
|
211
|
+
evidence: [...verdict.evidence, adviceFor(code, template)],
|
|
212
|
+
verify: "nifra check",
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// A comment ends at `-->` or `--!>`.
|
|
216
|
+
const COMMENT_END = /--!?>/g;
|
|
217
|
+
/** The comment opened at `start`, which HTML ends at `-->` or `--!>`; `<!-->` and `<!--->` are empty. */
|
|
218
|
+
function commentAt(text, start) {
|
|
219
|
+
const body = start + 4;
|
|
220
|
+
if (text.startsWith(">", body))
|
|
221
|
+
return { start, bodyEnd: body, end: body + 1 };
|
|
222
|
+
if (text.startsWith("->", body))
|
|
223
|
+
return { start, bodyEnd: body, end: body + 2 };
|
|
224
|
+
COMMENT_END.lastIndex = body;
|
|
225
|
+
const close = COMMENT_END.exec(text);
|
|
226
|
+
return close === null
|
|
227
|
+
? { start, bodyEnd: text.length, end: text.length }
|
|
228
|
+
: { start, bodyEnd: close.index, end: close.index + close[0].length };
|
|
229
|
+
}
|
|
230
|
+
/** The end of a markup tag or `{expression}`, ignoring `>`/braces inside quoted values. */
|
|
231
|
+
function markupEnd(text, start, expression = false) {
|
|
232
|
+
let quote;
|
|
233
|
+
let braces = expression ? 1 : 0;
|
|
234
|
+
for (let at = start; at < text.length; at++) {
|
|
235
|
+
const char = text[at];
|
|
236
|
+
if (quote !== undefined) {
|
|
237
|
+
if (braces > 0 && char === "\\")
|
|
238
|
+
at++;
|
|
239
|
+
else if (char === quote)
|
|
240
|
+
quote = undefined;
|
|
241
|
+
}
|
|
242
|
+
else if (char === '"' || char === "'" || (braces > 0 && char === "`"))
|
|
243
|
+
quote = char;
|
|
244
|
+
else if (char === "{")
|
|
245
|
+
braces++;
|
|
246
|
+
else if (char === "}") {
|
|
247
|
+
braces--;
|
|
248
|
+
if (expression && braces === 0)
|
|
249
|
+
return at + 1;
|
|
250
|
+
}
|
|
251
|
+
else if (!expression && braces === 0 && char === ">")
|
|
252
|
+
return at + 1;
|
|
253
|
+
}
|
|
254
|
+
return text.length;
|
|
255
|
+
}
|
|
256
|
+
/** Scan markup, not script strings, HTML comments or other tags' quoted attributes. The existing
|
|
257
|
+
* componentScripts scanner only extracts scripts and cannot distinguish these template regions. */
|
|
258
|
+
function templateHrefs(text, vue) {
|
|
259
|
+
const hrefs = [];
|
|
260
|
+
const comments = [];
|
|
261
|
+
let templateDepth = 0;
|
|
262
|
+
for (let at = 0; at < text.length;) {
|
|
263
|
+
if (text.startsWith("<!--", at)) {
|
|
264
|
+
const comment = commentAt(text, at);
|
|
265
|
+
comments.push(comment);
|
|
266
|
+
at = comment.end;
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (text[at] === "{" && (!vue || text.startsWith("{{", at))) {
|
|
270
|
+
at = markupEnd(text, at + 1, true);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (text[at] !== "<") {
|
|
274
|
+
at++;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const tag = /^<(\/?)([\w-]+)(?=[\s/>])/.exec(text.slice(at));
|
|
278
|
+
if (tag === null) {
|
|
279
|
+
at++;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const tagAt = at;
|
|
283
|
+
const end = markupEnd(text, at + tag[0].length);
|
|
284
|
+
const name = tag[2]?.toLowerCase();
|
|
285
|
+
const closing = tag[1] === "/";
|
|
286
|
+
at = end;
|
|
287
|
+
if (!closing && (name === "script" || name === "style")) {
|
|
288
|
+
const close = name === "script" ? /<\/script\s*>/gi : /<\/style\s*>/gi;
|
|
289
|
+
close.lastIndex = end;
|
|
290
|
+
const match = close.exec(text);
|
|
291
|
+
at = match === null ? text.length : close.lastIndex;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (name === "template")
|
|
295
|
+
templateDepth += closing ? -1 : 1;
|
|
296
|
+
if (closing || name !== "a" || (vue && templateDepth <= 0))
|
|
297
|
+
continue;
|
|
298
|
+
ATTRIBUTE.lastIndex = tagAt + tag[0].length;
|
|
299
|
+
for (let match = ATTRIBUTE.exec(text); match !== null; match = ATTRIBUTE.exec(text)) {
|
|
300
|
+
const [whole, attribute, doubled, single, braceDouble, braceSingle, braceTemplate] = match;
|
|
301
|
+
if (attribute !== "href" && attribute !== ":href" && attribute !== "v-bind:href")
|
|
302
|
+
continue;
|
|
303
|
+
const raw = doubled ?? single;
|
|
304
|
+
const value = attribute === "href"
|
|
305
|
+
? (raw ?? braceDouble ?? braceSingle ?? braceTemplate)
|
|
306
|
+
: raw
|
|
307
|
+
?.match(BOUND_LITERAL)
|
|
308
|
+
?.slice(1)
|
|
309
|
+
.find((part) => part !== undefined);
|
|
310
|
+
if (value !== undefined)
|
|
311
|
+
hrefs.push({
|
|
312
|
+
at: ATTRIBUTE.lastIndex - whole.length + whole.indexOf(attribute),
|
|
313
|
+
tagAt,
|
|
314
|
+
value,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Adapt only real HTML comments to the shared directive parser. Non-comment code stays a block
|
|
319
|
+
// boundary; quoted marker text cannot suppress anything. Line counts are unchanged.
|
|
320
|
+
const code = (part) => part.replace(/[^\s]/g, "x");
|
|
321
|
+
let expectations = "";
|
|
322
|
+
let previous = 0;
|
|
323
|
+
for (const comment of comments) {
|
|
324
|
+
expectations += code(text.slice(previous, comment.start));
|
|
325
|
+
expectations += text
|
|
326
|
+
.slice(comment.start + 4, comment.bodyEnd)
|
|
327
|
+
.split("\n")
|
|
328
|
+
.map((line) => `// ${line}`)
|
|
329
|
+
.join("\n");
|
|
330
|
+
previous = comment.end;
|
|
331
|
+
}
|
|
332
|
+
expectations += code(text.slice(previous));
|
|
333
|
+
return { hrefs, expectationLines: expectations.split("\n") };
|
|
334
|
+
}
|
|
335
|
+
/** The 1-based line of an offset in `text`: a search over the line starts, so a file with thousands of links is not re-split for each. */
|
|
336
|
+
function lineLookup(text) {
|
|
337
|
+
const starts = [0];
|
|
338
|
+
for (let at = text.indexOf("\n"); at !== -1; at = text.indexOf("\n", at + 1))
|
|
339
|
+
starts.push(at + 1);
|
|
340
|
+
return (offset) => {
|
|
341
|
+
let low = 0;
|
|
342
|
+
let high = starts.length - 1;
|
|
343
|
+
while (low < high) {
|
|
344
|
+
const mid = (low + high + 1) >> 1;
|
|
345
|
+
if ((starts[mid] ?? 0) <= offset)
|
|
346
|
+
low = mid;
|
|
347
|
+
else
|
|
348
|
+
high = mid - 1;
|
|
349
|
+
}
|
|
350
|
+
return low + 1;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
async function templateFindings(ctx, routes, kind, code, severity) {
|
|
354
|
+
const findings = [];
|
|
355
|
+
const files = [];
|
|
356
|
+
for await (const entry of new Glob("**/*.{vue,svelte}").scan({ cwd: ctx.root, dot: false })) {
|
|
357
|
+
// Bun yields `\` paths on Windows, which IGNORED and TEST_DIR (and the reported location) expect as `/`.
|
|
358
|
+
const file = toPosix(entry);
|
|
359
|
+
if (!IGNORED.test(file) && !TEST_DIR.test(file))
|
|
360
|
+
files.push(file);
|
|
361
|
+
}
|
|
362
|
+
for (const file of files.sort()) {
|
|
363
|
+
// The source index holds only a component's script blocks; the links are in its template.
|
|
364
|
+
const text = readFileSync(join(ctx.root, file), "utf8");
|
|
365
|
+
if (!text.includes("href"))
|
|
366
|
+
continue;
|
|
367
|
+
const { hrefs, expectationLines } = templateHrefs(text, file.endsWith(".vue"));
|
|
368
|
+
const lineOf = lineLookup(text);
|
|
369
|
+
for (const { at, tagAt, value } of hrefs) {
|
|
370
|
+
if (!value.startsWith("/") || value.startsWith("//"))
|
|
371
|
+
continue;
|
|
372
|
+
// A Svelte `{expression}` inside the value is a hole.
|
|
373
|
+
const verdict = judge(routes, value.replace(/\$?\{[^}]*\}/g, ANCHOR_HOLE));
|
|
374
|
+
if (verdict?.kind !== kind)
|
|
375
|
+
continue;
|
|
376
|
+
const line = lineOf(at);
|
|
377
|
+
const tagLine = lineOf(tagAt);
|
|
378
|
+
if (commentBlockExpectation(expectationLines, tagLine, [code, "internal-link"]) !== undefined ||
|
|
379
|
+
commentBlockExpectation(expectationLines, line, [code, "internal-link"]) !== undefined)
|
|
380
|
+
continue;
|
|
381
|
+
findings.push(report(code, severity, file, line, verdict, undefined, true));
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return findings;
|
|
385
|
+
}
|
|
386
|
+
function internalLinkRule(code, title, kind, severity) {
|
|
387
|
+
return {
|
|
388
|
+
code,
|
|
389
|
+
title,
|
|
390
|
+
async scan(ctx) {
|
|
391
|
+
const routes = await pageRoutes(ctx);
|
|
392
|
+
if (routes === undefined)
|
|
393
|
+
return [];
|
|
394
|
+
const scripts = await scanSources(ctx, {
|
|
395
|
+
expectation: [code, "internal-link"],
|
|
396
|
+
mayMatch: (text) => text.includes("<a") && text.includes("href"),
|
|
397
|
+
find: (facts, tree) => TEST_DIR.test(tree.fileName)
|
|
398
|
+
? []
|
|
399
|
+
: facts.internalAnchors(tree).flatMap((anchor) => {
|
|
400
|
+
const verdict = judge(routes, anchor.path);
|
|
401
|
+
if (verdict?.kind !== kind)
|
|
402
|
+
return [];
|
|
403
|
+
return [
|
|
404
|
+
{
|
|
405
|
+
position: anchor.position,
|
|
406
|
+
report: (line, note) => report(code, severity, tree.fileName, line, verdict, note),
|
|
407
|
+
},
|
|
408
|
+
];
|
|
409
|
+
}),
|
|
410
|
+
});
|
|
411
|
+
return [...scripts, ...(await templateFindings(ctx, routes, kind, code, severity))];
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
export const deadInternalLinkRule = internalLinkRule("NF-C057", "Internal link to a path no page serves", "dead", "warn");
|
|
416
|
+
export const uncheckedInternalLinkRule = internalLinkRule("NF-C058", "Internal link written as a path string", "unchecked", "info");
|
|
417
|
+
export const internalLinkRules = Object.freeze([deadInternalLinkRule, uncheckedInternalLinkRule]);
|
|
418
|
+
//# sourceMappingURL=internal-links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intern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AO,CAAC,GAAG,OAAO,EAAE,GAAG,CAAC,MAAM,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;QACrF,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAClD,SAAS,EACT,wCAAwC,EACxC,MAAM,EACN,MAAM,CACP,CAAA;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CACvD,SAAS,EACT,wCAAwC,EACxC,WAAW,EACX,MAAM,CACP,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,yBAAyB,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../src/rules/legacy.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAA;AAExD;yDACyD;AACzD,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmB7D,CAAA;AAuBF,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAmB7C,CAAA;
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../src/rules/legacy.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAA;AAExD;yDACyD;AACzD,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmB7D,CAAA;AAuBF,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAmB7C,CAAA;AAqnCF,qFAAqF;AACrF,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAkB1C,CAAA"}
|
package/dist/rules/legacy.js
CHANGED
|
@@ -336,9 +336,29 @@ const typecheckRule = {
|
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
findings.push(...outsideProgramFindings(tc.outsideProgram ?? []));
|
|
339
|
+
if (tc.routeTableOutsideProgram !== undefined)
|
|
340
|
+
findings.push(routeTableFinding(tc.routeTableOutsideProgram));
|
|
339
341
|
return findings;
|
|
340
342
|
},
|
|
341
343
|
};
|
|
344
|
+
/** The route table exists but no program loads it: every `to` and `search` stays loose, silently. */
|
|
345
|
+
function routeTableFinding(file) {
|
|
346
|
+
return legacyDiagnostic("typecheck", {
|
|
347
|
+
severity: "warning",
|
|
348
|
+
file,
|
|
349
|
+
message: `${file} is outside tsc's program, so navigate, redirect and Link accept any target and search: no route imports its ./+types module, and no tsconfig names the table`,
|
|
350
|
+
fix: `Add "${file}" to tsconfig.json "files" (a "files" entry is not filtered by "exclude"), or import a route's ./+types module from a file the program holds`,
|
|
351
|
+
suggestion: {
|
|
352
|
+
kind: "manual",
|
|
353
|
+
title: "Load the generated route table",
|
|
354
|
+
steps: [
|
|
355
|
+
`Add "${file}" to the "files" array in tsconfig.json, or in another tsconfig the typecheck runs.`,
|
|
356
|
+
'List it under "files", not "include": an "exclude" that names ".nifra" would drop it from "include".',
|
|
357
|
+
"Run `nifra check` again; links and redirects are now checked against the app's routes.",
|
|
358
|
+
],
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
}
|
|
342
362
|
/** One finding per zone folder: the fix (tsconfig `include`) is per folder, not per file. */
|
|
343
363
|
function outsideProgramFindings(files) {
|
|
344
364
|
const byFolder = new Map();
|