mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 14:50:02 +00:00
fix(lint): honor data-no-timeline on root compositions (#2228)
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user