feat(lint): warn on repeated tl.fromTo() on one selector without a tl.set baseline [P2]#2075
Open
miguel-heygen wants to merge 1 commit into
Open
feat(lint): warn on repeated tl.fromTo() on one selector without a tl.set baseline [P2]#2075miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
….set baseline GSAP applies a fromTo()'s `from` vars to the DOM at authoring time regardless of timeline position. When the SAME string-literal selector gets 2+ fromTo() calls with no earlier tl.set()/gsap.set() baseline, the LAST-authored `from` value becomes the resting state for any seek before the first tween, e.g. a z-index:999 overlay rendered solid black across ~40% of the timeline while lint/validate/inspect passed clean. New rule gsap_repeated_fromto_without_baseline extends the existing gsap static analysis: warns (not errors) when a byte-identical string-literal selector has 2+ fromTo windows and no set() baseline for it. Conservative to avoid the repo's history of gsap false positives: literal selectors only, skipped when any set targets the same literal, skipped for dynamic selectors.
b679d2c to
f6bf77f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
tl.fromTo(SELECTOR, { from }, { to }, laterTime)applies itsfromvaluesto the DOM at authoring time (GSAP's immediateRender), regardless of the
tween's timeline position. When the same string-literal selector gets 2+
tl.fromTo()calls with no earliertl.set()baseline, the last-authoredfrombecomes the element's resting state for any seek before the firsttween actually runs, e.g. a z-index:999 overlay rendered solid black across
~40% of the timeline.
hyperframes lint/validate/inspectall pass cleantoday for this pattern.
Fix
New warning-severity rule:
gsap_repeated_fromto_without_baseline, extendingthe existing GSAP static analysis in
packages/lint/src/rules/gsap.ts.Per script/timeline: groups
fromToGSAP windows by target selector; for anyselector with 2+
fromTocalls, checks for atl.set/gsap.setbaseline onthat exact selector (before or at the first
fromTo). If no baseline exists,fires one finding per offending selector with a
fixHintsuggestingtl.set(selector, { ...safe resting values... }, 0).False-positive guards
This repo has a real history of GSAP false positives, so the rule is
conservative:
token/substring matching.
never fire.
fromTocall on a selector never fires.fromTocalls on different selectors never fire together.tl.set/gsap.seton the exact same literal selector suppresses thefinding.
Tests
Added 4 tests to
packages/lint/src/rules/gsap.test.ts:tl.fromTocalls target one selector without atl.setbaselinetl.fromTocalls have an earliertl.setbaseline
tl.fromTocall on a selectortl.fromTocalls target different selectorsbunx vitest run packages/lint/src/rules/gsap.test.ts: 86 passed.bunx oxlint/bunx oxfmt --check: clean.