Skip to content

fix(css/parser): bom parsing#9259

Merged
ematipico merged 1 commit intomainfrom
fix/css-bom-parser
Feb 27, 2026
Merged

fix(css/parser): bom parsing#9259
ematipico merged 1 commit intomainfrom
fix/css-bom-parser

Conversation

@ematipico
Copy link
Member

Summary

Parsing of BOM was incorrect. The identifier lexing was including BOM as identifeir, breaking stuff.

I moved the BOM lexing before the identifier lexing.

Had help with AI.

Test Plan

Now we match prettier's formatting, so a snapshot was deleted

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: 1c692fd

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

@ematipico ematipico requested review from a team February 27, 2026 09:28
@github-actions github-actions bot added A-Parser Area: parser A-Formatter Area: formatter L-CSS Language: CSS labels Feb 27, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7bf12b and 1c692fd.

⛔ Files ignored due to path filters (1)
  • crates/biome_css_formatter/tests/specs/prettier/css/bom/bom.css.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • .changeset/fix-css-bom-formatting.md
  • crates/biome_css_parser/src/lexer/mod.rs

Walkthrough

Fixes a CSS formatter issue where Byte Order Mark (BOM) at the start of a file caused selector collapse. The parser lexer now prioritises BOM detection when at file position zero, preserving line breaks between comments and selectors in BOM-prefixed CSS files to align with Prettier's behaviour. Changes consolidate BOM logic into the initial Unicode identifier token handling branch and include a minor token mapping adjustment.

Suggested labels

A-Parser, L-CSS

Suggested reviewers

  • dyc3
  • denbezrukov
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing BOM (byte order mark) parsing in the CSS parser, which is the core issue addressed across all modified files.
Description check ✅ Passed The description clearly relates to the changeset, explaining the BOM parsing problem, the solution (moving BOM lexing before identifier lexing), and acknowledging AI assistance as required.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/css-bom-parser

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

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 27, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 187 skipped benchmarks1


Comparing fix/css-bom-parser (1c692fd) with main (2d0b8e6)

Open in CodSpeed

Footnotes

  1. 187 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.

Copy link
Contributor

@denbezrukov denbezrukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥🔥🔥

@denbezrukov
Copy link
Contributor

I'm wondering how you found this?

@ematipico
Copy link
Member Author

I'm wondering how you found this?

I checked the Prettier tests we have, and noticed we have snapshot for the BOM formatting

@ematipico ematipico merged commit 96939c0 into main Feb 27, 2026
17 checks passed
@ematipico ematipico deleted the fix/css-bom-parser branch February 27, 2026 12:23
@github-actions github-actions bot mentioned this pull request Feb 27, 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 L-CSS Language: CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants