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