fix(lint): catch visible css before composition root#1751
Merged
Conversation
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.
Summary
head_leaked_textso it also scans the</head>→<body>boundary and the body prefix before the first composition root<style><body>, and negative cases for validstyle/scriptblocks and in-root code samplesWhy
A generated composition can be browser-parseable while still visibly rendering leaked CSS text before the actual HyperFrames composition root. The previous lint rule only inspected content inside
<head>...</head>, so CSS emitted after</head>but before<body>was missed and could become visible in preview/render output.I tested general-purpose validators while investigating:
parse5parses like browsers and returned no parse errors for the malformed boundary case, so it is too permissive for this video-composition contract.html-validate/htmlhinteither missed the boundary leak or produced unrelated document-style noise under practical configs.markuplintcan catch some orphan-end-tag shapes, but does not catch CSS text before the composition root after<body>.v.Nuis better suited as optional CI/developer validation, but it requires Java or a separate binary and is too heavy for the hot lint path.The root contract here is HyperFrames-specific: no CSS/code-looking text may be visible before the composition root unless it is inside a non-rendered/valid block.
Verification
bun --filter @hyperframes/core test -- src/lint/rules/core.test.ts— 40 tests passedbun --filter @hyperframes/core test -- src/lint/rules— 251 tests passedbun --filter @hyperframes/core test— 2138 passed, 5 skipped, 3 todohead_leaked_texterror with the leakedbody { ... }snippet