Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alissonlauffer
Copy link
Contributor

Summary:

A regression was introduced in commit e27892b, which caused frontmatter parsing to break when a // was present in any string. I'm not sure if it is necessary to create an issue before this PR, but I can open one if wanted.

Playground link: https://biomejs.dev/playground/?indentStyle=space&indentWidth=4&bracketSameLine=true&code=LQAtAC0ACgBjAG8AbgBzAHQAIAB0AGUAcwB0ACAAPQAgACIALwAvACIAOwAKAC0ALQAtAAoACgA8AGQAaQB2AD4AewB0AGUAcwB0AH0APAAvAGQAaQB2AD4ACgA%3D&language=astro

Test Plan

All current tests pass, as does a newly created test.

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

🦋 Changeset detected

Latest commit: d11b3f7

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 L-HTML Language: HTML and super languages labels Nov 4, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Walkthrough

This PR fixes a regression in Astro frontmatter parsing where comment-like sequences (e.g. // or /*) inside quoted strings were being treated as real comments, prematurely ending frontmatter parsing. The lexer’s quote-tracking (QuotesSeen::check_byte) now only recognises comment entry when no quotes are currently open. A test verifying frontmatter with a string containing a comment-like sequence was added.

Possibly related PRs

Suggested reviewers

  • dyc3

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing comment detection in Astro frontmatter when quote-enclosed strings contain comment-like sequences.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the regression, its cause, and the test plan.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e48080 and d11b3f7.

📒 Files selected for processing (1)
  • .changeset/fix-astro-frontmatter-comments.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Test Node.js API
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: autofix

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/fix-astro-frontmatter-comments.md (1)

7-7: Optional: Consider adding a comma for clarity.

The sentence "The issue was in the QuotesSeen logic which was detecting..." would be slightly clearer as "The issue was in the QuotesSeen logic, which was detecting..." (non-restrictive clause). Minor nitpick though—the meaning is perfectly clear as is.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b28f5f and 0e48080.

⛔ Files ignored due to path filters (1)
  • crates/biome_html_parser/tests/html_specs/ok/astro/comment_in_frontmatter.astro.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (3)
  • .changeset/fix-astro-frontmatter-comments.md (1 hunks)
  • crates/biome_html_parser/src/lexer/mod.rs (1 hunks)
  • crates/biome_html_parser/tests/html_specs/ok/astro/comment_in_frontmatter.astro (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/specs/html/**/*.html : Place HTML test cases under tests/specs/html as .html files discovered by the test macro

Applied to files:

  • crates/biome_html_parser/tests/html_specs/ok/astro/comment_in_frontmatter.astro
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/spec_tests.rs : In tests/spec_tests.rs, generate tests with `tests_macros::gen_tests! {"tests/specs/html/**/*.html", crate::spec_test::run, ""}`

Applied to files:

  • crates/biome_html_parser/tests/html_specs/ok/astro/comment_in_frontmatter.astro
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/comments.rs : Define HtmlCommentStyle implementing CommentStyle in comments.rs

Applied to files:

  • crates/biome_html_parser/src/lexer/mod.rs
📚 Learning: 2025-10-15T09:24:31.042Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:24:31.042Z
Learning: Lexer must implement the biome_parser::Lexer trait

Applied to files:

  • crates/biome_html_parser/src/lexer/mod.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/comments.rs : Expose a public HtmlComments type alias: `pub type HtmlComments = Comments<HtmlLanguage>;`

Applied to files:

  • crates/biome_html_parser/src/lexer/mod.rs
🪛 LanguageTool
.changeset/fix-astro-frontmatter-comments.md

[uncategorized] ~7-~7: Possible missing comma found.
Context: ...";. The issue was in the QuotesSeen logic which was detecting comment markers (/...

(AI_HYDRA_LEO_MISSING_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
🔇 Additional comments (2)
crates/biome_html_parser/src/lexer/mod.rs (1)

1059-1065: Excellent fix for the regression.

The additional conditions correctly ensure that comment detection only occurs when not inside any string literals. By checking all three quote counters (single, double, template) are zero, the lexer now properly handles strings containing comment-like sequences such as "//".

crates/biome_html_parser/tests/html_specs/ok/astro/comment_in_frontmatter.astro (1)

1-5: Perfect test case for the regression.

This minimal example directly targets the issue where "//" inside a string literal caused premature frontmatter termination. Well-crafted test.

@dyc3 dyc3 requested review from a team November 4, 2025 22:29
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you

@ematipico ematipico merged commit 4855c4a into biomejs:main Nov 5, 2025
13 checks passed
@github-actions github-actions bot mentioned this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants