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

Skip to content

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Nov 20, 2025

Summary

This makes the parser reject trivia between v-foo and : in vue directives.

It does this by inspecting p.source().trivia_list to check for trivia.

It was suggested to use relexing for this use case, but I chose not to for a couple reasons.

  1. I don't want to actually change what these tokens are lexed as.
  2. The token source skips over whitespace tokens, so I would probably end up just having to do something like this anyway.

fixes #8174

Test Plan

added tests

Docs

@changeset-bot
Copy link

changeset-bot bot commented Nov 20, 2025

🦋 Changeset detected

Latest commit: e57fdd9

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 L-HTML Language: HTML and super languages labels Nov 20, 2025
@dyc3 dyc3 marked this pull request as ready for review November 20, 2025 14:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 20, 2025

Walkthrough

This PR fixes Vue directive parsing in the HTML formatter and parser. When a Vue directive like v-else is followed by whitespace and then a property binding (e.g. :property="123"), the parser now correctly recognises them as two separate directives rather than attempting to parse them as a single combined directive. The fix detects trivia between the directive name and colon, completing the directive early and returning control. Includes a changeset entry, test specs, and parser logic modifications.

Possibly related PRs

Suggested reviewers

  • ematipico

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: preventing whitespace before Vue directive arguments by rejecting trivia between directive names and colons.
Description check ✅ Passed The description clearly explains the motivation, implementation approach, reasoning for design decisions, and references the fixed issue #8174.
Linked Issues check ✅ Passed The PR addresses issue #8174 by implementing parser changes to reject whitespace between Vue directive names and arguments, preventing incorrect merging of separate directives.
Out of Scope Changes check ✅ Passed All changes are focused on fixing Vue directive parsing: parser logic, test specs for both parser and formatter, and a changeset entry—all directly addressing the issue.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dyc3/vue-directive-whitespace

📜 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 0c8349e and e57fdd9.

⛔ Files ignored due to path filters (2)
  • crates/biome_html_formatter/tests/specs/html/vue/issue-8174.vue.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_parser/tests/html_specs/ok/vue/issue-8174.vue.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • .changeset/dry-cooks-start.md (1 hunks)
  • crates/biome_html_formatter/tests/specs/html/vue/issue-8174.vue (1 hunks)
  • crates/biome_html_parser/src/syntax/vue.rs (1 hunks)
  • crates/biome_html_parser/tests/html_specs/ok/vue/issue-8174.vue (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). (6)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
🔇 Additional comments (4)
crates/biome_html_formatter/tests/specs/html/vue/issue-8174.vue (1)

1-2: Perfect test case!

Concise and directly validates the fix for the whitespace handling between v-else and :property.

crates/biome_html_parser/tests/html_specs/ok/vue/issue-8174.vue (1)

1-2: LGTM!

Mirrors the formatter test appropriately to validate parser behaviour.

.changeset/dry-cooks-start.md (1)

1-10: Clear documentation!

The changeset effectively explains the fix with a helpful before/after example.

crates/biome_html_parser/src/syntax/vue.rs (1)

22-33: The trivia detection logic is sound.

Based on the codebase, trivia_list is a Vec<Trivia> that accumulates trivia incrementally during lexing, not a monolithic collection containing the entire source. When you call .last(), you get the most recently lexed trivia entry. Since the parser has just moved from pos (directive name start) to the colon, that last trivia is guaranteed to be within that range. The checkpoint/rewind mechanism further ensures stale entries are truncated. The condition pos < last_trivia.text_range().start() correctly identifies trivia between the directive name and colon—no risk of false positives from distant trivia.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

@dyc3 dyc3 added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit 6ba4157 Nov 20, 2025
13 checks passed
@dyc3 dyc3 deleted the dyc3/vue-directive-whitespace branch November 20, 2025 14:53
@github-actions github-actions bot mentioned this pull request Nov 20, 2025
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-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📝 Vue v-else combined with property

3 participants