fix(lint): honor data-no-timeline on root compositions (#2228)

This commit is contained in:
Miguel Ángel
2026-07-11 18:32:15 -04:00
committed by GitHub
parent 6b7431bf45
commit c18391b98c
2 changed files with 11 additions and 1 deletions
+9
View File
@@ -227,6 +227,15 @@ describe("core rules", () => {
expect(finding).toBeDefined(); expect(finding).toBeDefined();
}); });
it("allows a timeline-free root that explicitly declares data-no-timeline", async () => {
const html = `
<html><body>
<div id="root" data-composition-id="c1" data-no-timeline data-width="1920" data-height="1080" data-duration="5"></div>
</body></html>`;
const result = await lintHyperframeHtml(html);
expect(result.findings.find((f) => f.code === "missing_timeline_registry")).toBeUndefined();
});
it("does not flag missing_timeline_registry on a sub-composition (inherits from host)", async () => { it("does not flag missing_timeline_registry on a sub-composition (inherits from host)", async () => {
const html = ` const html = `
<html><body> <html><body>
+2 -1
View File
@@ -264,11 +264,12 @@ export const coreRules: Array<(ctx: LintContext) => HyperframeLintFinding[]> = [
}, },
// missing_timeline_registry + timeline_registry_missing_init // missing_timeline_registry + timeline_registry_missing_init
({ source, rawSource, options }) => { ({ source, rawSource, rootTag, options }) => {
// Sub-compositions inherit window.__timelines from the host composition // Sub-compositions inherit window.__timelines from the host composition
if (options.isSubComposition || rawSource.trimStart().toLowerCase().startsWith("<template")) { if (options.isSubComposition || rawSource.trimStart().toLowerCase().startsWith("<template")) {
return []; return [];
} }
if (/(?:^|\s)data-no-timeline(?=[\s=/]|$)/i.test(rootTag?.attrs || "")) return [];
const findings: HyperframeLintFinding[] = []; const findings: HyperframeLintFinding[] = [];
if ( if (
!TIMELINE_REGISTRY_INIT_PATTERN.test(source) && !TIMELINE_REGISTRY_INIT_PATTERN.test(source) &&