fix(lint): handle newlines in useVueValidVElse and useVueValidVElseIf#8821
fix(lint): handle newlines in useVueValidVElse and useVueValidVElseIf#8821dyc3 merged 8 commits intobiomejs:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 061a512 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 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 |
WalkthroughReplaces directive name comparisons to use 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
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 |
ematipico
left a comment
There was a problem hiding this comment.
Since you haven't opened an issue, I find it very difficult to understand what we're fixing. You could have shared a playground too.
For example, I believe the comments aren't playing any part in the issue, because I couldn't reproduce the problem with the snapshot you used.
crates/biome_html_analyze/src/lint/nursery/use_vue_valid_v_else.rs
Outdated
Show resolved
Hide resolved
|
Please use the following code snippet: <template>
<div>
<div v-if="condition"></div>
<div v-else><span v-if="condition2" /></div>
<div
v-if="condition"
data-attr1
data-attr2
data-attr3
data-attr4
data-attr5
data-attr6
/>
<div v-else></div>
</div>
</template>I am also sharing a link to the playground |
dyc3
left a comment
There was a problem hiding this comment.
I don't think that sample you posted is in any of your new snapshot tests.
Important
This PR was generated with the help of Antigravity (Google DeepMind), an AI coding assistant.
Summary
This PR fixes multiple bugs in the Vue conditional rules (
useVueValidVIf,useVueValidVElse, anduseVueValidVElseIf):v-if: Fixed a bug inuseVueValidVIfwhere it incorrectly identified the containing element for directives on self-closing tags, leading to false positive conflict diagnostics with parent element attributes.text_trimmed()for directive name comparisons across all rules to ensure directives are correctly identified even when preceded by newlines in multiline tag formatting.Motivation:
These issues caused incorrect linting errors in standard Vue template patterns, such as documented conditional blocks or nested components using self-closing syntax.
Changes:
has_previous_sibling_with_v_if_or_else_ifto traverse siblings iteratively, skipping nodes containing only whitespace (usingtext_trimmed().is_empty()).find_conflicting_else_directivesto check theHtmlAttributeListof the directive's parent directly, supporting both normal and self-closing tags.text_trimmed().Test Plan
The fixes are verified using the project's spec test suite with new comprehensive test cases:
valid.vuefor all three rules covering:<span v-if="cond"/>inside av-elseblock).cargo test -p biome_html_analyze --test spec_testsDocs
Not applicable as these are bug fixes for existing rules and do not introduce new options.