Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(require-default-prop): avoid requiring defaults for optional props not included in destructuring#2768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
yuasa-engineer wants to merge2 commits intovuejs:master
base:master
Choose a base branch
Loading
fromyuasa-engineer:fix/require-default-prop-optional-destructuring

Conversation

yuasa-engineer
Copy link

@yuasa-engineeryuasa-engineer commentedJun 24, 2025
edited
Loading

Fixes#2767

If this approach doesn't align with the project's direction, please don't hesitate to reject this proposal. In that case, you may also close the corresponding issue.

What type of PR is this?

bug fix / enhancement

What does this PR do? / Why do we need it?

This PR fixes a regression in thevue/require-default-prop rule introduced in v10.1.0. The rule was requiring default values for ALL optional props when using props destructuring, even if those props were not included in the destructuring pattern.

Before this fix

// Was forced to destructure all optional props, even unused onesconst{ used, unused=undefined}=defineProps<{used?:string;unused?:string;// Only used in template, forced to assign undefined}>()

After this fix

// Only need to provide defaults for actually destructured optional propsconst{ used='default'}=defineProps<{used?:string;// Destructured, so needs defaultunused?:string;// Not destructured, no default needed}>()

What changes did you make? (Give an overview)

  1. Modifiedlib/rules/require-default-prop.js:

    • Added logic to check if an optional prop is actually included in the destructuring pattern
    • Only requires default values for optional props that are explicitly destructured
    • Usesutils.getPropsDestructure(node) to get destructured props and check if optional prop exists
  2. Updated test cases intests/lib/rules/require-default-prop.js:

    • Added valid test cases for optional props not included in destructuring
    • Updated invalid test cases to properly test mixed scenarios
    • Added comprehensive test coverage for the new behavior

Which issue(s) does this PR fix?

Fixes#2767
Related to#2725 and#2741

Additional context

This change maintains backward compatibility and only reduces false positive warnings. The rule continues to work as expected for:

  • Required props (still checked)
  • Optional props with explicit destructuring (still requires defaults)
  • Boolean props (still exempt)
  • Props usingwithDefaults() (still works)

The fix specifically addresses the user feedback that the previous fix was too aggressive and made Vue 3.5's props destructuring unnecessarily verbose.

…s not included in destructuring- Only require default values for optional props that are explicitly destructured- Optional props not included in destructuring pattern are now ignored- Fixes regression introduced in v10.1.0 where all optional props required defaults
@changeset-botchangeset-bot
Copy link

changeset-botbot commentedJun 24, 2025
edited
Loading

🦋 Changeset detected

Latest commit:88b94f2

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

This PR includes changesets to release 1 package
NameType
eslint-plugin-vuePatch

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

vue/require-default-prop: Avoid requiring defaults for optional props not included in destructuring
1 participant
@yuasa-engineer

[8]ページ先頭

©2009-2025 Movatter.jp