Skip to content

Commit ddbf0ad

Browse files
committed
fix(lint): remove root_composition_missing_data_duration
Lint cannot statically observe the runtime's true Infinity-emission condition: it requires a finite GSAP timeline duration AND a finite media/sub-comp window AND timeline > floor + 1, none of which are visible to the static linter. The looping shapes that drive the condition are already covered by `gsap_infinite_repeat` and `gsap_repeat_ceil_overshoot` (both from #243), which point at the real authoring mistake — flagging the missing duration separately was a noisy proxy for the same signal. Per #490 review discussion, deprecate the static rule and let those two GSAP rules carry the pre-render coverage. If perfect precision on `durationInFrames = Infinity` is needed, that belongs on the runtime/render path where `shouldEmitNonDeterministicInf` is actually known. Add regression tests pinning the removal: a docs-compliant root without `data-duration` no longer warns, and the canonical loop-inflated shape now surfaces only via `gsap_infinite_repeat` instead of two duplicate findings.
1 parent 82fab98 commit ddbf0ad

2 files changed

Lines changed: 59 additions & 20 deletions

File tree

‎packages/core/src/lint/rules/composition.test.ts‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,63 @@ describe("composition rules", () => {
380380
expect(finding).toBeUndefined();
381381
});
382382
});
383+
384+
describe("root_composition_missing_data_duration (removed)", () => {
385+
// The rule was a static proxy for the runtime's loop-inflation Infinity
386+
// emission, but lint cannot observe GSAP timeline duration statically and
387+
// the looping shapes that drive it are already covered by
388+
// `gsap_infinite_repeat` and `gsap_repeat_ceil_overshoot`. The rule has
389+
// been removed (#243's Infinity-emission concern is now carried by those
390+
// GSAP rules); these tests pin the removal so the rule does not silently
391+
// come back.
392+
393+
it("does not warn on a docs-compliant root with no data-duration", () => {
394+
// The documented authoring model: root composition without
395+
// data-duration, runtime derives it from the GSAP timeline.
396+
const html = `<!DOCTYPE html><html><body>
397+
<div data-composition-id="docs" data-width="1920" data-height="1080" data-start="0">
398+
<video src="clip.mp4" data-start="0" data-track-index="0" muted playsinline></video>
399+
</div>
400+
<script>
401+
window.__timelines = window.__timelines || {};
402+
window.__timelines["docs"] = gsap.timeline({ paused: true });
403+
</script>
404+
</body></html>`;
405+
const result = lintHyperframeHtml(html);
406+
const finding = result.findings.find(
407+
(f) => f.code === "root_composition_missing_data_duration",
408+
);
409+
expect(finding).toBeUndefined();
410+
});
411+
412+
it("does not warn even on the original Infinity-risk shape (no media, looping timeline)", () => {
413+
// This was the canonical "warn" case under the old rule — root with no
414+
// data-duration, no media, GSAP timeline driven by repeat: -1. The
415+
// looping shape itself is now flagged by `gsap_infinite_repeat`; the
416+
// duplicate `root_composition_missing_data_duration` warning is gone.
417+
const html = `<!DOCTYPE html><html><body>
418+
<div data-composition-id="loopy" data-width="1920" data-height="1080" data-start="0">
419+
<div class="caption" data-start="1" data-duration="2">hello</div>
420+
</div>
421+
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js"></script>
422+
<script>
423+
window.__timelines = window.__timelines || {};
424+
const tl = gsap.timeline({ paused: true });
425+
tl.to(".caption", { x: 100, duration: 1, repeat: -1 });
426+
window.__timelines["loopy"] = tl;
427+
</script>
428+
</body></html>`;
429+
const result = lintHyperframeHtml(html);
430+
// The deprecated rule must not fire.
431+
const removedFinding = result.findings.find(
432+
(f) => f.code === "root_composition_missing_data_duration",
433+
);
434+
expect(removedFinding).toBeUndefined();
435+
// The looping shape is still surfaced — by `gsap_infinite_repeat`,
436+
// which is the more actionable signal pointing at the real authoring
437+
// mistake.
438+
const gsapFinding = result.findings.find((f) => f.code === "gsap_infinite_repeat");
439+
expect(gsapFinding).toBeDefined();
440+
});
441+
});
383442
});

‎packages/core/src/lint/rules/composition.ts‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,6 @@ export const compositionRules: Array<(ctx: LintContext) => HyperframeLintFinding
210210
return findings;
211211
},
212212

213-
// root_composition_missing_data_duration
214-
({ rootTag }) => {
215-
const findings: HyperframeLintFinding[] = [];
216-
if (!rootTag) return findings;
217-
const compId = readAttr(rootTag.raw, "data-composition-id");
218-
if (!compId) return findings;
219-
const hasDuration = readAttr(rootTag.raw, "data-duration") !== null;
220-
if (!hasDuration) {
221-
findings.push({
222-
code: "root_composition_missing_data_duration",
223-
severity: "warning",
224-
message: `Root composition "${compId}" is missing data-duration. Without an explicit duration, the runtime may infer Infinity for compositions with repeating animations, causing playback issues.`,
225-
fixHint:
226-
'Add data-duration="X" to the root composition element, where X is the total duration in seconds.',
227-
snippet: truncateSnippet(rootTag.raw),
228-
});
229-
}
230-
return findings;
231-
},
232-
233213
// standalone_composition_wrapped_in_template
234214
({ rawSource, options }) => {
235215
const findings: HyperframeLintFinding[] = [];

0 commit comments

Comments
 (0)