fix: ignore WRN component examples in import validation
Quality / quality (ubuntu-latest) (push) Failing after 10m54s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 19:13:28 +05:30
parent 8e6dca0751
commit 7ba7c8a73f
5 changed files with 33 additions and 8 deletions
+18 -4
View File
@@ -21,6 +21,7 @@ import {
generateTargets,
resolveWrnImports,
type PageAst,
type ViewNode,
} from "@wrnexus/compiler";
import type { Context, Middleware } from "@wrnexus/core";
@@ -342,14 +343,27 @@ function importedValueBindings(ast: PageAst): Set<string> {
return names;
}
function validateConfiguredImports(source: string, ast: PageAst, file: string): void {
function viewComponentNames(nodes: ViewNode[], names = new Set<string>()): Set<string> {
for (const node of nodes) {
if (node.type === "element") {
if (/^[A-Z]/.test(node.tag)) names.add(node.tag);
viewComponentNames(node.children, names);
} else if (node.type === "each") {
viewComponentNames(node.body, names);
viewComponentNames(node.empty, names);
} else if (node.type === "if") {
for (const branch of node.branches) viewComponentNames(branch.body, names);
}
}
return names;
}
function validateConfiguredImports(_source: string, ast: PageAst, file: string): void {
const root = projectRootForFile(file);
const options = compileImportOptions.get(resolve(root));
if (!options || options.mode === "legacy") return;
const imported = importedValueBindings(ast);
const usedComponents = new Set(
Array.from(source.matchAll(/<([A-Z][A-Za-z0-9_$]*)\b/g), (match) => match[1]!),
);
const usedComponents = viewComponentNames(ast.view);
const compilerBuiltins = new Set([
"Async",
"Component",