Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for props destructure to vue/require-valid-default-prop rule #2551

Merged
merged 3 commits into from
Sep 18, 2024

Conversation

ota-meshi
Copy link
Member

This PR modifies the vue/require-valid-default-prop rule to add support for props destructure.

related to #2121

@ota-meshi ota-meshi mentioned this pull request Sep 13, 2024
6 tasks
@@ -259,8 +257,7 @@ ruleTester.run('require-valid-default-prop', rule, {
parser: require('@typescript-eslint/parser'),
ecmaVersion: 6,
sourceType: 'module'
},
errors: errorMessage('function')
}
Copy link
Member

Choose a reason for hiding this comment

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

These changes are not really related to your changes, right? It was just missed before and you cleaned it up here?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right 😄

@ota-meshi ota-meshi merged commit 05b7559 into vuejs:master Sep 18, 2024
18 checks passed
@aethr
Copy link

aethr commented Oct 16, 2024

I think default values for arrays and objects are handled slightly differently when using props destructuring. I don't believe it's necessary to use a function to construct them, as shown in the example in https://vuejs.org/api/sfc-script-setup.html#reactive-props-destructure:

interface Props {
  msg?: string
  labels?: string[]
}

const { msg = 'hello', labels = ['one', 'two'] } = defineProps<Props>()

I've opened an issue: #2578

@ota-meshi ota-meshi deleted the vue-3.5-require-valid-default-prop branch October 16, 2024 01:33
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