Add support for props destructure to vue/require-valid-default-prop
rule by ota-meshi · Pull Request #2551 · vuejs/eslint-plugin-vue (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation3 Commits3 Checks11 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
This PR modifies the vue/require-valid-default-prop
rule to add support for props destructure.
related to #2121
@@ -259,8 +257,7 @@ ruleTester.run('require-valid-default-prop', rule, { |
---|
parser: require('@typescript-eslint/parser'), |
ecmaVersion: 6, |
sourceType: 'module' |
}, |
errors: errorMessage('function') |
} |
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?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right 😄
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()
I've opened an issue: #2578
ota-meshi deleted the vue-3.5-require-valid-default-prop branch