mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 19:36:04 +00:00
fix(lint): skip installed component snippets
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user