feat(define-props-destructuring): add only-when-assigned option - #3009
Conversation
🦋 Changeset detectedLatest commit: cba9f25 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
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.
only-when-assigned option
only-when-assigned optiononly-when-assigned option
|
Hi, I’ve added the |
resolves #3006