Skip to content

feat(define-props-destructuring): add only-when-assigned option - #3009

Merged
FloEdelmann merged 8 commits into
vuejs:masterfrom
rzzf:fix/3006
Feb 13, 2026
Merged

feat(define-props-destructuring): add only-when-assigned option#3009
FloEdelmann merged 8 commits into
vuejs:masterfrom
rzzf:fix/3006

Conversation

@rzzf

@rzzf rzzf commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

resolves #3006

@changeset-bot

changeset-bot Bot commented Jan 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cba9f25

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 Minor

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

@waynzh waynzh 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.

Thanks, LGTM!

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

This PR fixes a false positive issue in the vue/define-props-destructuring rule where it incorrectly reported an error when defineProps was called without any assignment (e.g., defineProps(['foo']) or defineProps<{ foo?: string }>()).

Changes:

  • Modified the rule logic to check if there's a left-hand side assignment before enforcing destructuring preferences
  • Added comprehensive test coverage for the bug scenario with multiple variants (array syntax, TypeScript syntax, with/without withDefaults)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
lib/rules/define-props-destructuring.js Added check for left-hand side assignment to prevent false positives when defineProps is called without assignment
lib/utils/index.js Exported the existing getLeftOfDefineProps utility function for use in the rule
tests/lib/rules/define-props-destructuring.js Added 8 new valid test cases covering different scenarios where defineProps is called without assignment
.changeset/shy-ends-help.md Added changeset documenting the bug fix as a patch version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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.

@rzzf rzzf changed the title fix(define-props-destructuring): false positives when no assignment is made fix(define-props-destructuring): add only-when-assigned option Jan 22, 2026
@rzzf rzzf changed the title fix(define-props-destructuring): add only-when-assigned option feat(define-props-destructuring): add only-when-assigned option Jan 22, 2026
@rzzf

rzzf commented Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

Hi, I’ve added the only-when-assigned option. When you have time, please review again, thanks!

@rzzf
rzzf requested a review from waynzh January 22, 2026 10:19
Comment thread .changeset/shy-ends-help.md Outdated

@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! 🙂

Comment thread .changeset/shy-ends-help.md Outdated
Comment thread docs/rules/define-props-destructuring.md
Comment thread docs/rules/define-props-destructuring.md Outdated
@FloEdelmann
FloEdelmann merged commit 57058ce into vuejs:master Feb 13, 2026
16 checks passed
@github-actions github-actions Bot mentioned this pull request Feb 13, 2026
@rzzf
rzzf deleted the fix/3006 branch February 14, 2026 02:19
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.

vue/define-props-destructuring erroring when no assignment occurs

4 participants