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

The repeated fromTo baseline lint hint now points at immediateRender: false. Hint text only; rule logic unchanged.
This commit is contained in:
miga-heygen
2026-10-02 05:06:17 -07:00
committed by GitHub
parent 9afafa79ec
commit 1248639e71
2 changed files with 27 additions and 3 deletions
+23
View File
@@ -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 () => {
+4 -3
View File
@@ -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")),
});
}