Skip to content

Write HTML. Render video. Built for agents.

fix(lint): point the repeated fromTo baseline hint at immediateRender: false (#3895)

miga-heygen1248639e71e0
diff --git a/packages/lint/src/rules/gsap.test.ts b/packages/lint/src/rules/gsap.test.ts
index e4a0798cd2..0f8dc49499 100644
--- a/packages/lint/src/rules/gsap.test.ts
+++ b/packages/lint/src/rules/gsap.test.ts
@@ -3056,6 +3056,29 @@ describe("SVG draw-on rules", () => {
expect(finding?.severity).toBe("warning");
expect(finding?.selector).toBe("#ring");
+ expect(finding?.fixHint).toContain("every fromTo except the earliest-positioned one (at 5s)");
+ expect(finding?.fixHint).toContain("gsap_timeline_set_initial_hide");
+ });
+
+ it("gsap_repeated_fromto_without_baseline: accepts the hinted shape when the later tween is authored first", async () => {
+ const html = `
+<html><body>
+ <div data-composition-id="main" data-width="1920" data-height="1080"><div id="ring"></div></div>
+ <script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js"></script>
+ <script>
+ window.__timelines = window.__timelines || {};
+ const tl = gsap.timeline({ paused: true });
+ tl.fromTo("#ring", { opacity: 1 }, { opacity: 0, duration: 0.5, immediateRender: false }, 10);
+ tl.fromTo("#ring", { opacity: 0 }, { opacity: 1, duration: 0.5 }, 5);
+ window.__timelines.main = tl;
+ </script>
+</body></html>`;
+ const result = await lintHyperframeHtml(html);
+ const finding = result.findings.find(
+ (candidate) => candidate.code === "gsap_repeated_fromto_without_baseline",
+ );
+
+ expect(finding).toBeUndefined();
});
it("gsap_repeated_fromto_without_baseline: accepts explicit immediateRender false", async () => {
diff --git a/packages/lint/src/rules/gsap.ts b/packages/lint/src/rules/gsap.ts
index 215669de77..721d282578 100644
--- a/packages/lint/src/rules/gsap.ts
+++ b/packages/lint/src/rules/gsap.ts
@@ -1148,9 +1148,10 @@ export const gsapRules: LintRule<LintContext>[] = [
`(immediateRender), not at tween position.`,
selector,
fixHint:
- `Add \`immediateRender: false\` to the destination vars of each future fromTo, or set a safe ` +
- `resting state with an earlier \`tl.set("${selector}", { ... }, 0)\`. Pre-first-tween seeks must not ` +
- `inherit whichever fromTo call happened to author last.`,
+ `Add \`immediateRender: false\` to every fromTo except the earliest-positioned one ` +
+ `(at ${firstFromToPosition}s), so pre-first-tween seeks keep its "from" values. ` +
+ `A hiding \`tl.set(..., 0)\` baseline trips gsap_timeline_set_initial_hide, and a \`gsap.set\` ` +
+ `authored before the fromTo calls is overwritten by them.`,
snippet: truncateSnippet(fromToWindows.map((win) => win.raw).join("\n")),
});
}