-
-
Notifications
You must be signed in to change notification settings - Fork 760
fix(html): fix comment detection in Astro frontmatter #7989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(html): fix comment detection in Astro frontmatter #7989
Conversation
🦋 Changeset detectedLatest commit: d11b3f7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
WalkthroughThis PR fixes a regression in Astro frontmatter parsing where comment-like sequences (e.g. Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ 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)
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. Comment |
There was a problem hiding this 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
QuotesSeenlogic which was detecting..." would be slightly clearer as "The issue was in theQuotesSeenlogic, 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
⛔ Files ignored due to path filters (1)
crates/biome_html_parser/tests/html_specs/ok/astro/comment_in_frontmatter.astro.snapis excluded by!**/*.snapand 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.
ematipico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
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.