fix(core): correctly parse vue directives as expressions#9584
fix(core): correctly parse vue directives as expressions#9584
Conversation
🦋 Changeset detectedLatest commit: b6128e5 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 |
Parser conformance results onjs/262
jsx/babel
markdown/commonmark
symbols/microsoft
ts/babel
ts/microsoft
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
WalkthroughThis PR fixes Vue directive attribute value parsing so directive values containing object literals (e.g., Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment Tip CodeRabbit can generate a title for your PR based on the changes with custom instructions.Set the |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
crates/biome_html_analyze/tests/spec_tests.rs (1)
45-49: Minor observation:filteris now only used in the JSON scripts path.The
rule_filterandfiltervariables are constructed but only consumed byanalyze_and_snapin thescripts_from_jsonbranch. For the main path (line 70),analyze_with_workspacebuilds its own rule selector internally usinggroupandrule.This is fine and works correctly, but if you wanted to tidy up, these could be moved inside the
if let Some(scripts)block. Not a blocker.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_html_analyze/tests/spec_tests.rs` around lines 45 - 49, The variables rule_filter and filter (of type AnalysisFilter) are only used when scripts are loaded from JSON and passed into analyze_and_snap, while analyze_with_workspace constructs its own selector from group and rule; move the construction of RuleFilter::Rule (rule_filter) and the AnalysisFilter (filter) into the scripts_from_json branch (the if let Some(scripts) block) so they are only created when needed and avoid unused allocations in the main analyze_with_workspace path.crates/biome_test_utils/src/lib.rs (1)
931-935: Minor nit:.to_string()on aString.Line 932 uses
input_code.to_string()which clones the string. Semantically correct (the clone is needed sinceinput_codeis used later), but.clone()would signal intent more clearly.Not worth changing - just a style observation.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_test_utils/src/lib.rs` around lines 931 - 935, The field construction for FileContent::FromClient currently calls input_code.to_string(), which performs a clone of an existing String; replace that with input_code.clone() to make the intent explicit (i.e., in the struct initializer for FileContent::FromClient use input_code.clone() for the content field while leaving version and document_file_source unchanged).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/fix-vue-directive-expression-parsing.md:
- Line 5: Update the changeset entry text on line 5 of
.changeset/fix-vue-directive-expression-parsing.md to follow the bug-fix prefix
format by replacing the current free-form sentence with a line that begins with
"Fixed [`#NUMBER`](issue link): " followed by the existing description (e.g.,
"Fixed [`#NUMBER`](issue link): Fixed a bug where Vue directive attribute values
like `v-bind:class=\"{'dynamic': true}\"` were incorrectly parsed as JavaScript
statements instead of expressions..."). Ensure you include the issue number and
link in the square-bracket/parenthesis format before the rest of the message.
---
Nitpick comments:
In `@crates/biome_html_analyze/tests/spec_tests.rs`:
- Around line 45-49: The variables rule_filter and filter (of type
AnalysisFilter) are only used when scripts are loaded from JSON and passed into
analyze_and_snap, while analyze_with_workspace constructs its own selector from
group and rule; move the construction of RuleFilter::Rule (rule_filter) and the
AnalysisFilter (filter) into the scripts_from_json branch (the if let
Some(scripts) block) so they are only created when needed and avoid unused
allocations in the main analyze_with_workspace path.
In `@crates/biome_test_utils/src/lib.rs`:
- Around line 931-935: The field construction for FileContent::FromClient
currently calls input_code.to_string(), which performs a clone of an existing
String; replace that with input_code.clone() to make the intent explicit (i.e.,
in the struct initializer for FileContent::FromClient use input_code.clone() for
the content field while leaving version and document_file_source unchanged).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8bd0524c-1692-4275-9024-d7317004dd11
⛔ Files ignored due to path filters (80)
crates/biome_html_analyze/tests/specs/a11y/noRedundantAlt/invalid.html.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/noRedundantAlt/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/noRedundantAlt/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useAltText/vue/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useAnchorContent/astro/invalid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useAnchorContent/astro/valid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useAnchorContent/svelte/invalid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useAnchorContent/svelte/valid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useAnchorContent/vue/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useAnchorContent/vue/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useButtonType/invalid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useButtonType/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useButtonType/valid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useButtonType/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useIframeTitle/astro/invalid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useIframeTitle/astro/valid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useIframeTitle/svelte/invalid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useIframeTitle/svelte/valid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useIframeTitle/vue/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useIframeTitle/vue/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useMediaCaption/astro/invalid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useMediaCaption/astro/valid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useMediaCaption/svelte/invalid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useMediaCaption/svelte/valid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useMediaCaption/vue/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useMediaCaption/vue/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useValidLang/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useValidLang/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noDuplicateAttributes/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noDuplicateAttributes/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noScriptUrl/invalid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noScriptUrl/invalid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noScriptUrl/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noScriptUrl/valid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noScriptUrl/valid.html.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noScriptUrl/valid.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noScriptUrl/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noVueVIfWithVFor/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/noVueVIfWithVFor/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useScopedStyles/invalid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useScopedStyles/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useScopedStyles/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueConsistentVBindStyle/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueConsistentVBindStyle/longhand-invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueConsistentVBindStyle/longhand-valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueConsistentVBindStyle/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueConsistentVOnStyle/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueConsistentVOnStyle/longhand-invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueConsistentVOnStyle/longhand-valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueConsistentVOnStyle/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueHyphenatedAttributes/ignore/valid-ignored.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueHyphenatedAttributes/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueHyphenatedAttributes/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueVForKey/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueVForKey/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidTemplateRoot/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidTemplateRoot/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVBind/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVBind/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVCloak/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVCloak/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVElse/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVElse/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVElseIf/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVElseIf/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVHtml/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVHtml/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVIf/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVIf/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVOn/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVOn/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVOnce/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVOnce/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVPre/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVPre/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVText/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueValidVText/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueVapor/invalid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useVueVapor/valid.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/source/noDuplicateClasses/valid.html.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (24)
.changeset/fix-vue-directive-expression-parsing.mdcrates/biome_html_analyze/tests/spec_tests.rscrates/biome_html_analyze/tests/specs/a11y/noRedundantAlt/invalid.htmlcrates/biome_html_analyze/tests/specs/a11y/noRedundantAlt/invalid.vuecrates/biome_html_analyze/tests/specs/a11y/useAnchorContent/astro/valid.astrocrates/biome_html_analyze/tests/specs/a11y/useAnchorContent/svelte/valid.sveltecrates/biome_html_analyze/tests/specs/a11y/useAnchorContent/vue/valid.vuecrates/biome_html_analyze/tests/specs/nursery/noScriptUrl/valid.astrocrates/biome_html_analyze/tests/specs/nursery/noScriptUrl/valid.htmlcrates/biome_html_analyze/tests/specs/nursery/noScriptUrl/valid.sveltecrates/biome_html_analyze/tests/specs/nursery/noScriptUrl/valid.vuecrates/biome_html_analyze/tests/specs/nursery/useVueConsistentVBindStyle/longhand-invalid.options.jsoncrates/biome_html_analyze/tests/specs/nursery/useVueConsistentVBindStyle/longhand-valid.options.jsoncrates/biome_html_analyze/tests/specs/nursery/useVueConsistentVOnStyle/longhand-invalid.options.jsoncrates/biome_html_analyze/tests/specs/nursery/useVueConsistentVOnStyle/longhand-valid.options.jsoncrates/biome_html_analyze/tests/specs/nursery/useVueHyphenatedAttributes/ignore/valid-ignored.options.jsoncrates/biome_html_analyze/tests/specs/nursery/useVueValidVCloak/valid.vuecrates/biome_html_analyze/tests/specs/source/noDuplicateClasses/valid.htmlcrates/biome_js_analyze/tests/spec_tests.rscrates/biome_js_parser/src/syntax/program.rscrates/biome_js_syntax/src/file_source.rscrates/biome_service/src/file_handlers/html.rscrates/biome_service/src/file_handlers/vue.rscrates/biome_test_utils/src/lib.rs
💤 Files with no reviewable changes (2)
- crates/biome_html_analyze/tests/specs/a11y/noRedundantAlt/invalid.vue
- crates/biome_html_analyze/tests/specs/a11y/noRedundantAlt/invalid.html
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
This PR does two things:
analyze_with_workspacemethod in the HTML analyser. While doing so, I found some files that were incorrect.v-text=""v-bind:class="{ isActive: false }"allow_statementsflagTest Plan
The new infrastructure updates the code blocks in the snapshots, which explains the many changes. I also caught:
option.jsonfiles not correctly declaredDocs
N/A