Skip to content

fix(css): improve parsing recovery when encountering qualified rules inside CSS @page at-rule blocks#8905

Merged
dyc3 merged 2 commits intobiomejs:mainfrom
ryan-m-walker:fix/improve-parsing-recovery-in-at-rule-blocks
Jan 29, 2026
Merged

fix(css): improve parsing recovery when encountering qualified rules inside CSS @page at-rule blocks#8905
dyc3 merged 2 commits intobiomejs:mainfrom
ryan-m-walker:fix/improve-parsing-recovery-in-at-rule-blocks

Conversation

@ryan-m-walker
Copy link
Contributor

@ryan-m-walker ryan-m-walker commented Jan 29, 2026

Summary

closes #8428

This PR improves parsing recovery around the edge case where a user might try to use a CSS qualified rule inside an @page block. According to the spec only a declaration rule list is allowed in a @page block which treats qualified rules as invalid. This PR makes it so that qualified rules are parsed but treated as invalid. This allows us to consume the qualified rule block which would otherwise break parsing since the closing curly brace of the qualified rule would be treated as the closing brace of the @page block and cascade parsing errors further.

Note: the div:hover example in the snapshot tests still kinda breaks a bit due to it potentially being confused with a declaration but I didn't want to over-engineer the solution here with something like speculative parsing with try_parse since this mostly covers and edge case.

Test Plan

Snapshot tests

Docs

n/a

AI Usage Disclosure

I used Claude code to help explore the codebase and understand the problem a bit more and find existing solutions I could leverage, had it help me refine explanation comments, generate other test examples and double check my work but most of this was hand coded by me.

@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

🦋 Changeset detected

Latest commit: 65848a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-CSS Language: CSS labels Jan 29, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

This PR adds parsing recovery support for CSS @page at-rules that encounter qualified rules (which are disallowed in that context). The parser now detects qualified rules within @page blocks, reports them as errors, remaps them to bogus nodes, and continues parsing subsequent declarations. The formatter was updated to handle the CssBogus variant, the grammar was expanded to permit CssBogus in page at-rule items, and recovery logic was enhanced with an additional token. Test cases verify both error recovery and valid @page constructs.

Suggested labels

A-Parser, L-CSS

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: improving parsing recovery for qualified rules inside CSS @page at-rule blocks, which matches the changeset perfectly.
Description check ✅ Passed The description clearly explains the fix for issue #8428, detailing how qualified rules inside @page blocks are now parsed but marked invalid to improve recovery.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 29, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 126 skipped benchmarks1


Comparing ryan-m-walker:fix/improve-parsing-recovery-in-at-rule-blocks (65848a3) with main (21dba4a)

Open in CodSpeed

Footnotes

  1. 126 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@dyc3 dyc3 merged commit 9b1eea8 into biomejs:main Jan 29, 2026
20 checks passed
@github-actions github-actions bot mentioned this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: internal tools L-CSS Language: CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors parsing CSS @media print @page

2 participants