@@ -1550,8 +1550,12 @@ export const gsapRules: LintRule<LintContext>[] = [
15501550 } ,
15511551
15521552 // gsap_infinite_repeat
1553- ( { scripts } ) => {
1553+ ( { scripts, rootTag } ) => {
15541554 const findings : HyperframeLintFinding [ ] = [ ] ;
1555+ const declaredDuration = Number . parseFloat (
1556+ rootTag ? ( readAttr ( rootTag . raw , "data-duration" ) ?? "" ) : "" ,
1557+ ) ;
1558+ const hasFiniteCompositionWindow = Number . isFinite ( declaredDuration ) && declaredDuration > 0 ;
15551559 // Match repeat: -1 in GSAP tweens or timeline configs
15561560 const pattern = / r e p e a t \s * : \s * - 1 (? ! \d ) / g;
15571561 for ( const { snippet } of scanScriptsForRegexMatches ( scripts , pattern , {
@@ -1561,14 +1565,16 @@ export const gsapRules: LintRule<LintContext>[] = [
15611565 } ) ) {
15621566 findings . push ( {
15631567 code : "gsap_infinite_repeat" ,
1564- severity : "error" ,
1565- message :
1566- "GSAP tween uses `repeat: -1` (infinite). Infinite repeats break the deterministic " +
1567- "capture engine which seeks to exact frame times. Use a finite repeat count calculated " +
1568- "from the composition duration: `repeat: Math.max(0, Math.floor(duration / cycleDuration) - 1)`." ,
1569- fixHint :
1570- "Replace `repeat: -1` with a finite count, e.g. `repeat: Math.max(0, Math.floor(totalDuration / singleCycleDuration) - 1)`. " +
1571- "Use Math.floor (not Math.ceil) so the animation fits, and clamp at zero so a short composition cannot evaluate to -1." ,
1568+ severity : hasFiniteCompositionWindow ? "warning" : "error" ,
1569+ message : hasFiniteCompositionWindow
1570+ ? `GSAP tween uses \`repeat: -1\` (infinite), but the composition declares a finite ${ declaredDuration } s window. ` +
1571+ "HyperFrames clips deterministic seeking and export to that explicit duration."
1572+ : "GSAP tween uses `repeat: -1` (infinite) without a finite composition `data-duration`. " +
1573+ "The timeline can report an unbounded duration and make render planning fail." ,
1574+ fixHint : hasFiniteCompositionWindow
1575+ ? "Keep the explicit finite composition `data-duration`. Use a finite repeat count only when the loop itself must end before the composition does."
1576+ : "Add a finite composition `data-duration`, or replace `repeat: -1` with " +
1577+ "`repeat: Math.max(0, Math.floor(totalDuration / singleCycleDuration) - 1)`." ,
15721578 snippet : truncateSnippet ( snippet ) ,
15731579 } ) ;
15741580 }
0 commit comments