refactor(linter/vue): consolidate Vue component detection into shared utils#22559
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
Consolidates Vue component options object detection (the equivalent of upstream getVueObjectType / executeOnVue) into shared helpers in crates/oxc_linter/src/utils/vue.rs, replacing eight rule-local copies and broadening coverage to include Vue.mixin, Vue.extend, defineNuxtComponent, new Vue(...), and app.component / app.mixin.
Changes:
- Add
vue_component_options_kind,is_vue_component_options_object,is_vue_component_options_object_excluding_instance,is_vue_component_options_call, andis_in_vue_component_instance_methodinutils/vue.rs, with an explicitVueComponentObjectKindenum mirroring the upstream classification. - Remove duplicated detection helpers from 8 Vue rules (
valid_next_tick,return_in_emits_validator,return_in_computed_property,require_slots_as_functions,no_shared_component_data,no_deprecated_model_definition,no_deprecated_events_api,no_deprecated_data_object_declaration) and route them through the shared utilities. - Add fail-case fixtures for the newly recognized forms and update corresponding snapshots.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_linter/src/utils/vue.rs |
Adds shared Vue component options detection helpers and VueComponentObjectKind enum |
crates/oxc_linter/src/rules/vue/valid_next_tick.rs |
Drops local detection helpers; uses shared is_in_vue_component_instance_method; adds Vue.mixin / defineNuxtComponent tests |
crates/oxc_linter/src/rules/vue/return_in_emits_validator.rs |
Switches to shared is_vue_component_options_object; adds Vue.mixin fail case |
crates/oxc_linter/src/rules/vue/return_in_computed_property.rs |
Replaces is_vue_component_root ancestor check with shared helper; adds new Vue fail case |
crates/oxc_linter/src/rules/vue/require_slots_as_functions.rs |
Removes local helpers; uses shared util; adds Vue.mixin fail case |
crates/oxc_linter/src/rules/vue/no_shared_component_data.rs |
Uses is_vue_component_options_object_excluding_instance; adds Vue.mixin fail case |
crates/oxc_linter/src/rules/vue/no_deprecated_model_definition.rs |
Uses shared helper, including new Vue; adds new Vue fail case |
crates/oxc_linter/src/rules/vue/no_deprecated_events_api.rs |
Uses shared is_in_vue_component_instance_method; adds Vue.mixin / new Vue fail cases |
crates/oxc_linter/src/rules/vue/no_deprecated_data_object_declaration.rs |
Uses shared helper (broader than prior defineComponent-only check); adds Vue.mixin fail case |
crates/oxc_linter/src/snapshots/vue_*.snap (7 files) |
Snapshot updates for new failing test cases |
related #11440
follow-up to #22531.
getVueObjectType/executeOnVueequivalents) into sharedutils/vue.rs. 8 Vue rules migrated.Vue.mixin,defineNuxtComponent,new Vue, etc.) with test cases.Other Vue rules with extra checks or different visitor shapes are left as-is.
AI disclosure: implemented with Claude Code, reviewed manually.