From c84c30fd8d1cc0f124d6b64778c253f7d9d8f50d Mon Sep 17 00:00:00 2001 From: zhengqiuyang <54101044+zhengqiuyang@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:49:33 +0000 Subject: [PATCH] fix(lint): read a sub-composition mount's timing through the parser (#8037) `subcomposition_blanks_before_host` read `data-start` and `data-duration` with a raw `Number()`, so a mount with a reference start (`intro + 0.5`) looked like it started at 0 and was reported as leaving a blank tail that may not exist. A negative start was measured from the raw value, so the reported gap and the `data-duration` fix hint were wrong in the other direction. Read the mount through `readClipTiming`, the same contract parser the renderer uses: a runtime-resolved start is skipped (its end cannot be known statically), and a negative start is measured from zero. --- packages/lint/src/rules/composition.test.ts | 24 +++++++++++++++++++++ packages/lint/src/rules/composition.ts | 10 ++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/lint/src/rules/composition.test.ts b/packages/lint/src/rules/composition.test.ts index b6f40d1fb1..97498b5137 100644 --- a/packages/lint/src/rules/composition.test.ts +++ b/packages/lint/src/rules/composition.test.ts @@ -1836,6 +1836,30 @@ ${Array.from({ length: 10 }, (_, i) => `
{ + const html = ` +
+
+
+
+ `; + const result = await lintHyperframeHtml(html, { filePath: "/project/index.html" }); + expect(find(result.findings)).toBeUndefined(); + }); + + it("measures a negative start from zero, as the renderer does", async () => { + const html = ` +
+
+
+ `; + const result = await lintHyperframeHtml(html, { filePath: "/project/index.html" }); + const finding = find(result.findings); + expect(finding?.message).toContain("ends at 3s"); + expect(finding?.message).toContain("~7s"); + expect(finding?.fixHint).toContain("data-duration to 10"); + }); + it("stays silent on an intentional short intro followed by another clip", async () => { const html = `
diff --git a/packages/lint/src/rules/composition.ts b/packages/lint/src/rules/composition.ts index 85816007cd..4fb2f9a95c 100644 --- a/packages/lint/src/rules/composition.ts +++ b/packages/lint/src/rules/composition.ts @@ -1461,11 +1461,11 @@ export const compositionRules: Array<(ctx: LintContext) => HyperframeLintFinding const timed = tags .filter((tag) => tag.index !== rootTag.index && readAttr(tag.raw, "data-start") !== null) .map((tag) => { - const start = Number(readAttr(tag.raw, "data-start")) || 0; - const dur = Number(readAttr(tag.raw, "data-duration")); - const end = Number.isFinite(dur) && dur > 0 ? start + dur : Infinity; - return { tag, start, end }; - }); + const timing = readTagTiming(tag.raw); + if (timing.start === null) return null; + return { tag, start: timing.start, end: timing.end ?? Infinity }; + }) + .filter((row): row is { tag: OpenTag; start: number; end: number } => row !== null); // `tags` is a flat list (no nesting depth), so a timed element nested // *inside* a candidate slot is treated as a tail-covering sibling rather