fix(lint): skip installed component snippets

This commit is contained in:
Miguel Ángel
2026-07-12 17:52:53 +00:00
parent 9d91c2a23e
commit 7e6341b043
2 changed files with 18 additions and 0 deletions
+3
View File
@@ -217,6 +217,9 @@ export async function lintProject(projectDir: string): Promise<ProjectLintResult
const html = readFileSync(filePath, "utf-8");
const compSrcPath = `compositions/${file}`;
allHtmlSources.push({ html, compSrcPath });
// Registry components are pasteable snippets installed under this
// reserved directory, not independently renderable compositions.
if (file === "components" || file.startsWith("components/")) continue;
// Mountable fragments (figma component imports, registry snippets) are
// not standalone compositions — composition-root rules don't apply.
// Anchored to the file's ROOT element so a real composition that merely
+15
View File
@@ -26,6 +26,21 @@ async function lintWithFragment(name: string, html: string) {
}
describe("snippet fragment exemption", () => {
it("skips registry snippets installed under compositions/components", async () => {
const dir = mkdtempSync(join(tmpdir(), "hf-component-lint-"));
dirs.push(dir);
writeFileSync(join(dir, "index.html"), INDEX);
mkdirSync(join(dir, "compositions", "components"), { recursive: true });
writeFileSync(
join(dir, "compositions", "components", "grain-overlay.html"),
'<div id="grain-overlay"><div class="grain-texture"></div></div>',
);
const result = await lintProject(dir);
expect(result.results.map((entry) => entry.file)).toEqual(["index.html"]);
});
it("skips composition-root rules for files whose ROOT carries data-hf-snippet", async () => {
const findings = await lintWithFragment(
"frag.html",