@nifrajs/cli 5.8.0 → 5.9.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 +134 -0
- package/dist/agent-files.d.ts +0 -22
- package/dist/agent-files.d.ts.map +1 -1
- package/dist/agent-files.js +3 -1
- package/dist/agent-files.js.map +1 -1
- package/dist/assure-hydration.d.ts.map +1 -1
- package/dist/assure-hydration.js +2 -10
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +3 -3
- package/dist/assure.js.map +1 -1
- package/dist/check-scan.d.ts +2 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +54 -86
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts +3 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +20 -23
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +42 -13
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +20 -30
- package/dist/command-catalog.js.map +1 -1
- package/dist/config-target.js +1 -1
- package/dist/config-target.js.map +1 -1
- package/dist/db-child.js +3 -10
- package/dist/db-child.js.map +1 -1
- package/dist/db-config.d.ts +2 -0
- package/dist/db-config.d.ts.map +1 -1
- package/dist/db-config.js +2 -0
- package/dist/db-config.js.map +1 -1
- package/dist/doctor.d.ts +14 -3
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +91 -6
- package/dist/doctor.js.map +1 -1
- package/dist/frontend-guidance.d.ts +19 -0
- package/dist/frontend-guidance.d.ts.map +1 -1
- package/dist/frontend-guidance.js +267 -23
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/hand-built-manifest.d.ts.map +1 -1
- package/dist/hand-built-manifest.js +1 -1
- package/dist/hand-built-manifest.js.map +1 -1
- package/dist/internal/control-character.d.ts +3 -0
- package/dist/internal/control-character.d.ts.map +1 -0
- package/dist/internal/control-character.js +10 -0
- package/dist/internal/control-character.js.map +1 -0
- package/dist/internal/escape-regexp.d.ts +3 -0
- package/dist/internal/escape-regexp.d.ts.map +1 -0
- package/dist/internal/escape-regexp.js +5 -0
- package/dist/internal/escape-regexp.js.map +1 -0
- package/dist/internal/line-at.d.ts +3 -0
- package/dist/internal/line-at.d.ts.map +1 -0
- package/dist/internal/line-at.js +5 -0
- package/dist/internal/line-at.js.map +1 -0
- package/dist/internal/nifra-project.d.ts.map +1 -1
- package/dist/internal/nifra-project.js +35 -41
- package/dist/internal/nifra-project.js.map +1 -1
- package/dist/internal/posix-path.d.ts +3 -0
- package/dist/internal/posix-path.d.ts.map +1 -0
- package/dist/internal/posix-path.js +5 -0
- package/dist/internal/posix-path.js.map +1 -0
- package/dist/internal/project-specifiers.d.ts.map +1 -1
- package/dist/internal/project-specifiers.js +3 -10
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/realpath-or-self.d.ts +3 -0
- package/dist/internal/realpath-or-self.d.ts.map +1 -0
- package/dist/internal/realpath-or-self.js +11 -0
- package/dist/internal/realpath-or-self.js.map +1 -0
- package/dist/internal/record.d.ts +3 -0
- package/dist/internal/record.d.ts.map +1 -0
- package/dist/internal/record.js +5 -0
- package/dist/internal/record.js.map +1 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +28 -25
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/introspect.d.ts +0 -22
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +11 -151
- package/dist/introspect.js.map +1 -1
- package/dist/levels-tool.d.ts +2 -0
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +54 -64
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +6 -1
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js.map +1 -1
- package/dist/local-cli.d.ts +7 -0
- package/dist/local-cli.d.ts.map +1 -1
- package/dist/local-cli.js +13 -0
- package/dist/local-cli.js.map +1 -1
- package/dist/mcp-docs-tools.d.ts +1 -1
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +46 -3
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.d.ts +1 -1
- package/dist/mcp-http.js +2 -2
- package/dist/mcp-io.d.ts +16 -0
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +63 -0
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-isolate.d.ts.map +1 -1
- package/dist/mcp-isolate.js +2 -1
- package/dist/mcp-isolate.js.map +1 -1
- package/dist/mcp-project-child.d.ts.map +1 -1
- package/dist/mcp-project-child.js +5 -12
- package/dist/mcp-project-child.js.map +1 -1
- package/dist/mcp-render.d.ts.map +1 -1
- package/dist/mcp-render.js +9 -51
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-root.js +1 -1
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-run.d.ts.map +1 -1
- package/dist/mcp-run.js +3 -46
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp-ws.d.ts.map +1 -1
- package/dist/mcp-ws.js +2 -18
- package/dist/mcp-ws.js.map +1 -1
- package/dist/migrate-layout.d.ts.map +1 -1
- package/dist/migrate-layout.js +36 -57
- package/dist/migrate-layout.js.map +1 -1
- package/dist/output-schemas.d.ts.map +1 -1
- package/dist/output-schemas.js +7 -7
- package/dist/output-schemas.js.map +1 -1
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +1 -2
- package/dist/port.js.map +1 -1
- package/dist/ppr-read-fix.js +2 -2
- package/dist/ppr-read-fix.js.map +1 -1
- package/dist/recipes/5.9.0.d.ts +10 -0
- package/dist/recipes/5.9.0.d.ts.map +1 -0
- package/dist/recipes/5.9.0.js +41 -0
- package/dist/recipes/5.9.0.js.map +1 -0
- package/dist/recipes/index.d.ts +5 -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 +9 -13
- package/dist/review.js.map +1 -1
- package/dist/rules/contract-visibility.d.ts.map +1 -1
- package/dist/rules/contract-visibility.js +3 -9
- package/dist/rules/contract-visibility.js.map +1 -1
- package/dist/rules/data-guard.d.ts.map +1 -1
- package/dist/rules/data-guard.js +3 -10
- package/dist/rules/data-guard.js.map +1 -1
- package/dist/rules/pages.d.ts.map +1 -1
- package/dist/rules/pages.js +41 -58
- package/dist/rules/pages.js.map +1 -1
- package/dist/rules/routes.d.ts.map +1 -1
- package/dist/rules/routes.js +20 -27
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +206 -313
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/zones.d.ts.map +1 -1
- package/dist/rules/zones.js +3 -10
- package/dist/rules/zones.js.map +1 -1
- package/dist/runtime-differences.d.ts +62 -0
- package/dist/runtime-differences.d.ts.map +1 -0
- package/dist/runtime-differences.js +222 -0
- package/dist/runtime-differences.js.map +1 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +43 -43
- package/dist/sdk.js.map +1 -1
- package/dist/smoke.d.ts.map +1 -1
- package/dist/smoke.js +4 -12
- package/dist/smoke.js.map +1 -1
- package/dist/source-rewrites.d.ts +27 -0
- package/dist/source-rewrites.d.ts.map +1 -0
- package/dist/source-rewrites.js +402 -0
- package/dist/source-rewrites.js.map +1 -0
- package/dist/stylex-migrate.d.ts.map +1 -1
- package/dist/stylex-migrate.js +1 -1
- package/dist/stylex-migrate.js.map +1 -1
- package/dist/symptom-search.d.ts +5 -0
- package/dist/symptom-search.d.ts.map +1 -0
- package/dist/symptom-search.js +21 -0
- package/dist/symptom-search.js.map +1 -0
- package/dist/upgrade.d.ts +28 -3
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +153 -64
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +5 -3
- package/dist/verification-plan.js.map +1 -1
- package/docs/examples.json +32 -2
- package/docs/llms-full.txt +749 -95
- package/docs/types.json +300 -61
- package/package.json +11 -11
- package/src/agent-files.ts +4 -1
- package/src/assure-hydration.ts +2 -9
- package/src/assure.ts +3 -4
- package/src/check-scan.ts +65 -82
- package/src/check.ts +25 -23
- package/src/cli.ts +61 -13
- package/src/command-catalog.ts +22 -32
- package/src/config-target.ts +1 -1
- package/src/db-child.ts +3 -10
- package/src/db-config.ts +4 -0
- package/src/doctor.ts +128 -12
- package/src/frontend-guidance.ts +344 -25
- package/src/hand-built-manifest.ts +1 -2
- package/src/internal/control-character.ts +8 -0
- package/src/internal/escape-regexp.ts +4 -0
- package/src/internal/line-at.ts +4 -0
- package/src/internal/nifra-project.ts +39 -35
- package/src/internal/posix-path.ts +4 -0
- package/src/internal/project-specifiers.ts +3 -10
- package/src/internal/realpath-or-self.ts +10 -0
- package/src/internal/record.ts +4 -0
- package/src/internal/source-facts.ts +39 -29
- package/src/introspect.ts +16 -156
- package/src/levels-tool.ts +71 -78
- package/src/load.ts +6 -1
- package/src/local-cli.ts +12 -0
- package/src/mcp-docs-tools.ts +51 -3
- package/src/mcp-http.ts +2 -2
- package/src/mcp-io.ts +77 -0
- package/src/mcp-isolate.ts +2 -3
- package/src/mcp-project-child.ts +5 -14
- package/src/mcp-render.ts +11 -59
- package/src/mcp-root.ts +1 -1
- package/src/mcp-run.ts +5 -54
- package/src/mcp-ws.ts +2 -19
- package/src/migrate-layout.ts +52 -72
- package/src/output-schemas.ts +7 -8
- package/src/port.ts +1 -4
- package/src/ppr-read-fix.ts +2 -2
- package/src/recipes/5.9.0.ts +42 -0
- package/src/recipes/index.ts +7 -0
- package/src/review.ts +12 -15
- package/src/rules/contract-visibility.ts +3 -8
- package/src/rules/data-guard.ts +3 -10
- package/src/rules/pages.ts +47 -58
- package/src/rules/routes.ts +21 -27
- package/src/rules/security.ts +224 -255
- package/src/rules/zones.ts +3 -10
- package/src/runtime-differences.ts +302 -0
- package/src/sdk.ts +55 -58
- package/src/smoke.ts +4 -13
- package/src/source-rewrites.ts +463 -0
- package/src/stylex-migrate.ts +1 -3
- package/src/symptom-search.ts +27 -0
- package/src/upgrade.ts +194 -74
- package/src/verification-plan.ts +10 -4
package/src/rules/pages.ts
CHANGED
|
@@ -48,6 +48,25 @@ export function readStaticApiPrefix(source: string): StaticApiPrefix {
|
|
|
48
48
|
|
|
49
49
|
const CONFIG_FILES = [FRAMEWORK_FILE, CONFIG_FILE] as const
|
|
50
50
|
|
|
51
|
+
type RouteManifest = ReturnType<typeof discoverRoutes>
|
|
52
|
+
|
|
53
|
+
/** The routes/ manifest; `undefined` without the tree or for one it refuses, which dev and build report themselves. */
|
|
54
|
+
function routeManifest(routesDir: string): RouteManifest | undefined {
|
|
55
|
+
if (!existsSync(routesDir)) return undefined
|
|
56
|
+
try {
|
|
57
|
+
return discoverRoutes(routesDir)
|
|
58
|
+
} catch {
|
|
59
|
+
return undefined
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The manifest's script layouts, in code-unit order of their files. */
|
|
64
|
+
function scriptLayouts(manifest: RouteManifest): RouteManifest["layouts"][string][] {
|
|
65
|
+
return Object.values(manifest.layouts)
|
|
66
|
+
.filter((layout) => SCRIPT_LAYOUT.test(layout.file))
|
|
67
|
+
.sort((a, b) => codeUnitOrder(a.file, b.file))
|
|
68
|
+
}
|
|
69
|
+
|
|
51
70
|
export const shadowedPageRule: CheckRule = {
|
|
52
71
|
code: "NF-C027",
|
|
53
72
|
title: "Page route under the backend mount",
|
|
@@ -78,13 +97,8 @@ export const shadowedPageRule: CheckRule = {
|
|
|
78
97
|
}
|
|
79
98
|
if (apiPrefix === "") return []
|
|
80
99
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
manifest = discoverRoutes(routesDir)
|
|
84
|
-
} catch {
|
|
85
|
-
// A routes/ tree the manifest refuses fails dev and build with its own error.
|
|
86
|
-
return []
|
|
87
|
-
}
|
|
100
|
+
const manifest = routeManifest(routesDir)
|
|
101
|
+
if (manifest === undefined) return []
|
|
88
102
|
const findings: Diagnostic[] = []
|
|
89
103
|
for (const page of shadowedPages(manifest, [apiPrefix])) {
|
|
90
104
|
findings.push(
|
|
@@ -128,13 +142,8 @@ export const statusLayoutRule: CheckRule = {
|
|
|
128
142
|
title: "Root status page wraps the root layout itself",
|
|
129
143
|
async scan(ctx) {
|
|
130
144
|
const routesDir = join(ctx.root, "routes")
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
manifest = discoverRoutes(routesDir)
|
|
135
|
-
} catch {
|
|
136
|
-
return []
|
|
137
|
-
}
|
|
145
|
+
const manifest = routeManifest(routesDir)
|
|
146
|
+
if (manifest === undefined) return []
|
|
138
147
|
const layout = manifest.layouts._layout
|
|
139
148
|
if (layout === undefined) return []
|
|
140
149
|
const pages = [
|
|
@@ -240,6 +249,18 @@ function createWebAppCallee(
|
|
|
240
249
|
callee.name.text === "createWebApp"
|
|
241
250
|
}
|
|
242
251
|
|
|
252
|
+
/** The object literal a `createWebApp(...)` call takes as its options; `undefined` for any other node. */
|
|
253
|
+
function createWebAppOptions(
|
|
254
|
+
ts: typeof TSApi,
|
|
255
|
+
isCreateWebApp: (callee: TSApi.Expression) => boolean,
|
|
256
|
+
node: TSApi.Node,
|
|
257
|
+
): TSApi.ObjectLiteralExpression | undefined {
|
|
258
|
+
if (!ts.isCallExpression(node) || !isCreateWebApp(node.expression)) return undefined
|
|
259
|
+
const arg = node.arguments[0]
|
|
260
|
+
const options = arg === undefined ? undefined : unwrapExpression(ts, arg)
|
|
261
|
+
return options !== undefined && ts.isObjectLiteralExpression(options) ? options : undefined
|
|
262
|
+
}
|
|
263
|
+
|
|
243
264
|
const objectPropertyName = (
|
|
244
265
|
ts: typeof TSApi,
|
|
245
266
|
property: TSApi.ObjectLiteralElementLike,
|
|
@@ -318,15 +339,8 @@ export function entryApiMounts(
|
|
|
318
339
|
}
|
|
319
340
|
const mounts: EntryApiMount[] = []
|
|
320
341
|
const visit = (node: TSApi.Node): void => {
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
if (
|
|
324
|
-
ts.isCallExpression(node) &&
|
|
325
|
-
isCreateWebApp(node.expression) &&
|
|
326
|
-
options !== undefined &&
|
|
327
|
-
ts.isObjectLiteralExpression(options) &&
|
|
328
|
-
options.properties.some((property) => objectPropertyName(ts, property) === "api")
|
|
329
|
-
) {
|
|
342
|
+
const options = createWebAppOptions(ts, isCreateWebApp, node)
|
|
343
|
+
if (options?.properties.some((property) => objectPropertyName(ts, property) === "api")) {
|
|
330
344
|
// The last of an `apiPrefix` property and a spread decides, as it does at runtime.
|
|
331
345
|
let apiPrefix: EntryApiPrefix = { kind: "literal", value: "", unset: true }
|
|
332
346
|
let prefixNode: TSApi.Node | undefined
|
|
@@ -501,14 +515,8 @@ export function entryCopyChunksGaps(
|
|
|
501
515
|
manifest = statement.moduleSpecifier.text
|
|
502
516
|
const gaps: EntryCopyChunksGap[] = []
|
|
503
517
|
const visit = (node: TSApi.Node): void => {
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
if (
|
|
507
|
-
ts.isCallExpression(node) &&
|
|
508
|
-
isCreateWebApp(node.expression) &&
|
|
509
|
-
options !== undefined &&
|
|
510
|
-
ts.isObjectLiteralExpression(options)
|
|
511
|
-
) {
|
|
518
|
+
const options = createWebAppOptions(ts, isCreateWebApp, node)
|
|
519
|
+
if (options !== undefined) {
|
|
512
520
|
const names = options.properties.map((property) =>
|
|
513
521
|
ts.isSpreadAssignment(property) ? undefined : objectPropertyName(ts, property),
|
|
514
522
|
)
|
|
@@ -688,16 +696,9 @@ export const layoutMetaDataRule: CheckRule = {
|
|
|
688
696
|
title: "Layout meta reads data its layout never loads",
|
|
689
697
|
async scan(ctx) {
|
|
690
698
|
const routesDir = join(ctx.root, "routes")
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
manifest = discoverRoutes(routesDir)
|
|
695
|
-
} catch {
|
|
696
|
-
return []
|
|
697
|
-
}
|
|
698
|
-
const layouts = Object.values(manifest.layouts)
|
|
699
|
-
.filter((layout) => SCRIPT_LAYOUT.test(layout.file))
|
|
700
|
-
.sort((a, b) => codeUnitOrder(a.file, b.file))
|
|
699
|
+
const manifest = routeManifest(routesDir)
|
|
700
|
+
if (manifest === undefined) return []
|
|
701
|
+
const layouts = scriptLayouts(manifest)
|
|
701
702
|
if (layouts.length === 0) return []
|
|
702
703
|
const loaded = await loadRuleTypeScript(ctx)
|
|
703
704
|
const ts = loaded.compiler
|
|
@@ -784,16 +785,9 @@ export const ungatedLayoutRefusalRule: CheckRule = {
|
|
|
784
785
|
title: "Layout loader refuses access without a gate",
|
|
785
786
|
async scan(ctx) {
|
|
786
787
|
const routesDir = join(ctx.root, "routes")
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
manifest = discoverRoutes(routesDir)
|
|
791
|
-
} catch {
|
|
792
|
-
return []
|
|
793
|
-
}
|
|
794
|
-
const layouts = Object.values(manifest.layouts)
|
|
795
|
-
.filter((layout) => SCRIPT_LAYOUT.test(layout.file))
|
|
796
|
-
.sort((a, b) => codeUnitOrder(a.file, b.file))
|
|
788
|
+
const manifest = routeManifest(routesDir)
|
|
789
|
+
if (manifest === undefined) return []
|
|
790
|
+
const layouts = scriptLayouts(manifest)
|
|
797
791
|
if (layouts.length === 0) return []
|
|
798
792
|
const sources = layouts.map((layout) =>
|
|
799
793
|
[layout.file, ...(layout.backend === undefined ? [] : [layout.backend])].map((file) => ({
|
|
@@ -890,13 +884,8 @@ export const frontendServerExportRule: CheckRule = {
|
|
|
890
884
|
title: "Server-only export in a route frontend file",
|
|
891
885
|
async scan(ctx) {
|
|
892
886
|
const routesDir = join(ctx.root, "routes")
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
try {
|
|
896
|
-
manifest = discoverRoutes(routesDir)
|
|
897
|
-
} catch {
|
|
898
|
-
return []
|
|
899
|
-
}
|
|
887
|
+
const manifest = routeManifest(routesDir)
|
|
888
|
+
if (manifest === undefined) return []
|
|
900
889
|
const files = new Set<string>()
|
|
901
890
|
for (const entry of [
|
|
902
891
|
...manifest.routes,
|
package/src/rules/routes.ts
CHANGED
|
@@ -38,6 +38,19 @@ interface StaticRouteFact {
|
|
|
38
38
|
readonly path: string
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/** A project file's lines, each file read and split once per scan. */
|
|
42
|
+
function sourceLines(ctx: RuleContext): (file: string) => readonly string[] {
|
|
43
|
+
const linesByFile = new Map<string, readonly string[]>()
|
|
44
|
+
return (file) => {
|
|
45
|
+
let lines = linesByFile.get(file)
|
|
46
|
+
if (lines === undefined) {
|
|
47
|
+
lines = (ctx.project.source.read(file) ?? "").split("\n")
|
|
48
|
+
linesByFile.set(file, lines)
|
|
49
|
+
}
|
|
50
|
+
return lines
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
/** Parse-don't-cast over the project fact: a malformed entry is dropped, never trusted. */
|
|
42
55
|
function routeFacts(ctx: RuleContext): StaticRouteFact[] {
|
|
43
56
|
const raw: readonly unknown[] = ctx.project.routes
|
|
@@ -84,17 +97,13 @@ export const reservedSegmentRule: CheckRule = {
|
|
|
84
97
|
title: "Route segment collides with a reserved client proxy key",
|
|
85
98
|
async scan(ctx) {
|
|
86
99
|
const findings: Diagnostic[] = []
|
|
87
|
-
const
|
|
100
|
+
const linesOf = sourceLines(ctx)
|
|
88
101
|
for (const route of pathSites(routeFacts(ctx))) {
|
|
89
102
|
for (const segment of route.path.split("/")) {
|
|
90
103
|
if (segment === "") continue
|
|
91
104
|
const collision = reservedKeyFor(segment)
|
|
92
105
|
if (collision === undefined) continue
|
|
93
|
-
|
|
94
|
-
if (lines === undefined) {
|
|
95
|
-
lines = (ctx.project.source.read(route.file) ?? "").split("\n")
|
|
96
|
-
linesByFile.set(route.file, lines)
|
|
97
|
-
}
|
|
106
|
+
const lines = linesOf(route.file)
|
|
98
107
|
if (commentBlockExpectation(lines, route.line, RESERVED_SEGMENT_EXPECTATION) !== undefined)
|
|
99
108
|
continue
|
|
100
109
|
findings.push(
|
|
@@ -223,7 +232,7 @@ export const overlappingRouteRule: CheckRule = {
|
|
|
223
232
|
title: "Overlapping route registration",
|
|
224
233
|
async scan(ctx) {
|
|
225
234
|
const findings: Diagnostic[] = []
|
|
226
|
-
const
|
|
235
|
+
const linesOf = sourceLines(ctx)
|
|
227
236
|
const byFile = new Map<string, StaticRouteFact[]>()
|
|
228
237
|
for (const route of routeFacts(ctx)) {
|
|
229
238
|
const routes = byFile.get(route.file)
|
|
@@ -234,14 +243,7 @@ export const overlappingRouteRule: CheckRule = {
|
|
|
234
243
|
// As in NF-C019: two multi-method calls overlap once per shared method, reported once.
|
|
235
244
|
const reported = new Set<string>()
|
|
236
245
|
for (const [file, routes] of byFile) {
|
|
237
|
-
const lines = (): readonly string[] =>
|
|
238
|
-
let value = linesByFile.get(file)
|
|
239
|
-
if (value === undefined) {
|
|
240
|
-
value = (ctx.project.source.read(file) ?? "").split("\n")
|
|
241
|
-
linesByFile.set(file, value)
|
|
242
|
-
}
|
|
243
|
-
return value
|
|
244
|
-
}
|
|
246
|
+
const lines = (): readonly string[] => linesOf(file)
|
|
245
247
|
|
|
246
248
|
const expectationByLine = new Map<number, ReturnType<typeof commentBlockExpectation>>()
|
|
247
249
|
const expectationAt = (line: number): ReturnType<typeof commentBlockExpectation> => {
|
|
@@ -357,16 +359,12 @@ export const paramModifierRule: CheckRule = {
|
|
|
357
359
|
title: "Route param followed by an unsupported modifier",
|
|
358
360
|
async scan(ctx) {
|
|
359
361
|
const findings: Diagnostic[] = []
|
|
360
|
-
const
|
|
362
|
+
const linesOf = sourceLines(ctx)
|
|
361
363
|
for (const route of pathSites(routeFacts(ctx))) {
|
|
362
364
|
const forms = expandOptionalParams(route.path)
|
|
363
365
|
const text = literalModifier(forms[forms.length - 1] ?? route.path)
|
|
364
366
|
if (text === undefined) continue
|
|
365
|
-
|
|
366
|
-
if (lines === undefined) {
|
|
367
|
-
lines = (ctx.project.source.read(route.file) ?? "").split("\n")
|
|
368
|
-
linesByFile.set(route.file, lines)
|
|
369
|
-
}
|
|
367
|
+
const lines = linesOf(route.file)
|
|
370
368
|
if (commentBlockExpectation(lines, route.line, PARAM_MODIFIER_EXPECTATION) !== undefined)
|
|
371
369
|
continue
|
|
372
370
|
const character = text[text.length - 1]!
|
|
@@ -397,13 +395,9 @@ export const unresolvedRoutePathRule: CheckRule = {
|
|
|
397
395
|
title: "Route path the static scan cannot read",
|
|
398
396
|
async scan(ctx) {
|
|
399
397
|
const findings: Diagnostic[] = []
|
|
400
|
-
const
|
|
398
|
+
const linesOf = sourceLines(ctx)
|
|
401
399
|
for (const route of ctx.project.sourceFindings.routePaths) {
|
|
402
|
-
|
|
403
|
-
if (lines === undefined) {
|
|
404
|
-
lines = (ctx.project.source.read(route.file) ?? "").split("\n")
|
|
405
|
-
linesByFile.set(route.file, lines)
|
|
406
|
-
}
|
|
400
|
+
const lines = linesOf(route.file)
|
|
407
401
|
if (commentBlockExpectation(lines, route.line, DYNAMIC_PATH_EXPECTATION) !== undefined)
|
|
408
402
|
continue
|
|
409
403
|
findings.push(
|