Skip to content

refactor(linter/vue): consolidate Vue component detection into shared utils#22559

Merged
camc314 merged 3 commits into
oxc-project:mainfrom
babu-ch:refactor/vue-consolidate-component-detection
May 19, 2026
Merged

refactor(linter/vue): consolidate Vue component detection into shared utils#22559
camc314 merged 3 commits into
oxc-project:mainfrom
babu-ch:refactor/vue-consolidate-component-detection

Conversation

@babu-ch

@babu-ch babu-ch commented May 19, 2026

Copy link
Copy Markdown
Contributor

related #11440

follow-up to #22531.

  • 71e96f9: extract Vue component detection (getVueObjectType / executeOnVue equivalents) into shared utils/vue.rs. 8 Vue rules migrated.
  • e99ee48: cover newly-detected component forms (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.

@codspeed-hq

codspeed-hq Bot commented May 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing babu-ch:refactor/vue-consolidate-component-detection (ac883f1) with main (87f065e)2

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (ec7de07) during the generation of this report, so 87f065e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@babu-ch babu-ch marked this pull request as ready for review May 19, 2026 06:44
@babu-ch babu-ch requested a review from camc314 as a code owner May 19, 2026 06:44
@camc314 camc314 requested a review from Copilot May 19, 2026 07:21

@camc314 camc314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and is_in_vue_component_instance_method in utils/vue.rs, with an explicit VueComponentObjectKind enum 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

@camc314 camc314 merged commit ea6b4d6 into oxc-project:main May 19, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants