diff --git a/packages/lint/src/rules/gsap.test.ts b/packages/lint/src/rules/gsap.test.ts
index e08478bb98..fe1a3a5d68 100644
--- a/packages/lint/src/rules/gsap.test.ts
+++ b/packages/lint/src/rules/gsap.test.ts
@@ -671,6 +671,27 @@ describe("GSAP rules", () => {
expect(finding?.fixHint).toMatch(/xPercent/);
});
+ it("warns for every selector of a comma list with a CSS scale transform, not only the last", async () => {
+ const html = `
+
+
+
+
+`;
+ const result = await lintHyperframeHtml(html);
+ const finding = result.findings.find((f) => f.code === "gsap_css_transform_conflict");
+ expect(finding?.selector).toBe("#hero");
+ });
+
it("warns when tl.to animates scale on an element with CSS scale transform", async () => {
const html = `
@@ -3174,6 +3195,26 @@ describe("SVG draw-on rules", () => {
expect(finding).toBeUndefined();
});
+ it("gsap_timeline_set_initial_hide: counts every selector of a comma list as hidden by authored CSS", async () => {
+ const html = `
+
+
+
+`;
+ const result = await lintHyperframeHtml(html);
+ const findings = result.findings.filter((f) => f.code === "gsap_timeline_set_initial_hide");
+ expect(findings).toEqual([]);
+ });
+
it("gsap_timeline_set_initial_hide: does NOT warn when the target is already hidden by authored CSS", async () => {
// Defensive re-assertion: frame 0 is hidden by CSS anyway.
const html = `
diff --git a/packages/lint/src/rules/gsap.ts b/packages/lint/src/rules/gsap.ts
index 49acc4449a..5886ddd4e0 100644
--- a/packages/lint/src/rules/gsap.ts
+++ b/packages/lint/src/rules/gsap.ts
@@ -1,3 +1,4 @@
+import postcss from "postcss";
import { gsapCallOffset, containingCallOffset } from "../scriptPositions";
interface LintParsedGsap {
animations: Array<{
@@ -1017,6 +1018,27 @@ function indexInsideNonIifeRange(
// opacity to EXACTLY zero. The declaration regex is boundary-anchored so
// `opacity: 0.98` never matches; it ends at `;` or end of input, which also
// catches a final declaration without a trailing semicolon.
+function cssRuleSubjects(
+ styles: LintContext["styles"],
+): Array<{ declarations: string[]; subjects: string[] }> {
+ const rules: Array<{ declarations: string[]; subjects: string[] }> = [];
+ for (const style of styles) {
+ let root: postcss.Root;
+ try {
+ root = postcss.parse(style.content);
+ } catch {
+ continue;
+ }
+ root.walkRules((rule) => {
+ const subjects = rule.selectors.flatMap(
+ (selector) => /[#.][a-zA-Z0-9_-]+$/.exec(selector.trim())?.[0] ?? [],
+ );
+ if (subjects.length) rules.push({ declarations: rule.nodes.map(String), subjects });
+ });
+ }
+ return rules;
+}
+
function collectCssOpacityZeroSelectors(
styles: LintContext["styles"],
tags: OpenTag[],
@@ -1024,14 +1046,9 @@ function collectCssOpacityZeroSelectors(
const selectors = new Set();
const opacityExactlyZero = /opacity\s*:\s*0(?:\.0+)?\s*(?:;|$)/;
- for (const style of styles) {
- for (const [, selector, body] of style.content.matchAll(
- /([#.][a-zA-Z0-9_-]+)\s*\{([^}]+)\}/g,
- )) {
- if (body && opacityExactlyZero.test(body)) {
- selectors.add((selector ?? "").trim());
- }
- }
+ for (const { declarations, subjects } of cssRuleSubjects(styles)) {
+ if (!declarations.some((declaration) => opacityExactlyZero.test(declaration))) continue;
+ for (const subject of subjects) selectors.add(subject);
}
for (const tag of tags) {
@@ -1320,17 +1337,13 @@ export const gsapRules: LintRule[] = [
const cssScaleSelectors = new Map();
// Check