Skip to content

fix(no-unused-components): match registered names the way Vue resolves components - #3248

Merged
ota-meshi merged 3 commits into
vuejs:masterfrom
bardrop-oss:fix-no-unused-components-resolution
Nov 30, 2026
Merged

ota-meshi merged 3 commits into
vuejs:masterfrom
bardrop-oss:fix-no-unused-components-resolution

Conversation

@bardrop

@bardrop bardrop commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #1445

vue/no-unused-components treated a myComp registration as used by <MyComp>. Vue can't resolve that: resolveAsset only tries the used name, its camelized form, and its capitalized camelized form. So the rule stayed quiet while the component failed to resolve at runtime.

The rule now marks a registration as used only if its name is one of those three forms of a used name, same as Vue. <my-comp>, <myComp> and <MyComp> still find a MyComp registration; <MyComp> no longer finds myComp.

A non-string :is literal (<component :is="null" />, which renders nothing) is no longer added as a used name. Before, it crashed the rule whenever a PascalCase or camelCase component was registered.

  • 3 new invalid cases fail before and pass after; 3 more valid cases cover the forms Vue does resolve; 2 cases cover :is="null" / :is="1".
  • Full test suite, lint, markdownlint and tsc pass.
  • Updated the note in the rule docs and added a patch changeset.

@changeset-bot

changeset-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 799cff7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-vue 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

@FloEdelmann FloEdelmann changed the title title: fix(no-unused-components): match registered names the way Vue resolves components fix(no-unused-components): match registered names the way Vue resolves components Nov 12, 2026
Comment thread docs/rules/no-unused-components.md Resolved
Comment thread lib/rules/no-unused-components.ts Resolved

@FloEdelmann FloEdelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@FloEdelmann
FloEdelmann requested a review from a team November 13, 2026 11:03
@bardrop

bardrop commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the approval, @FloEdelmann. The branch is still clean against master and CI is green. Is there anything else you need from me before it can be merged?

@bardrop
bardrop force-pushed the fix-no-unused-components-resolution branch from 46dc7bc to ea0b0d0 Compare November 24, 2026 16:12

@ota-meshi ota-meshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for this PR!

Comment thread lib/utils/casing.ts Resolved
…s components

Vue resolves a component used as `name` by trying the registered names `name`, its camelized form, and its capitalized camelized form. The rule also accepted a camelCase registration used as PascalCase (e.g. `myComp` used as `<MyComp>`), which Vue cannot resolve, so it missed a real runtime error.

Fixes #1445
…in no-unused-components and no-undef-components
@bardrop
bardrop force-pushed the fix-no-unused-components-resolution branch from ea0b0d0 to 799cff7 Compare November 29, 2026 21:12

@ota-meshi ota-meshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thank you!

@ota-meshi
ota-meshi merged commit 0b51c93 into vuejs:master Nov 30, 2026
14 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 30, 2026
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.

update no-unused-components to not mix pascal/camel casing

3 participants