Skip to content

Write HTML. Render video. Built for agents.

fix(check): ignore registry component templates (#2450)

Miguel Ángel14df58f01713
diff --git a/packages/cli/src/utils/lintProject.test.ts b/packages/cli/src/utils/lintProject.test.ts
index 439ba1c202..d3c0204cd1 100644
--- a/packages/cli/src/utils/lintProject.test.ts
+++ b/packages/cli/src/utils/lintProject.test.ts
@@ -217,6 +217,21 @@ describe("lintProject", () => {
expect(results).toHaveLength(1);
});
+ it("ignores registry component templates under compositions/components", async () => {
+ const project = makeProject(validHtml());
+ const componentsDir = join(project, "compositions", "components", "unused-widget");
+ mkdirSync(componentsDir, { recursive: true });
+ writeFileSync(
+ join(componentsDir, "template.html"),
+ `<template><div data-duration="1">unused registry template</div></template>`,
+ );
+
+ const { results, totalErrors } = await lintProject(project);
+
+ expect(results.map((result) => result.file)).toEqual(["index.html"]);
+ expect(totalErrors).toBe(0);
+ });
+
it("ignores non-HTML files in compositions/", async () => {
const project = makeProject(validHtml(), {
"captions.html": validHtml("captions"),
diff --git a/packages/lint/src/project.ts b/packages/lint/src/project.ts
index a23226542f..8097962281 100644
--- a/packages/lint/src/project.ts
+++ b/packages/lint/src/project.ts
@@ -212,8 +212,13 @@ export async function lintProject(
const out: string[] = [];
for (const entry of readdirSync(dir, { withFileTypes: true })) {
const relPath = rel ? `${rel}/${entry.name}` : entry.name;
- if (entry.isDirectory()) out.push(...collectHtmlFiles(join(dir, entry.name), relPath));
- else if (entry.isFile() && entry.name.endsWith(".html") && !entry.name.startsWith("._")) {
+ if (entry.isDirectory()) {
+ // Registry components are source snippets, not independently mounted
+ // sub-compositions. Linting every installed template here makes an
+ // unused component fail the assembled project check.
+ if (!rel && entry.name === "components") continue;
+ out.push(...collectHtmlFiles(join(dir, entry.name), relPath));
+ } else if (entry.isFile() && entry.name.endsWith(".html") && !entry.name.startsWith("._")) {
out.push(relPath);
}
}