eslint-plugin-vue
eslint-plugin-vue copied to clipboard
vue/require-valid-default-prop does not work with type Object and return undefined
Checklist
- [x] I have tried restarting my IDE and the issue persists.
- [x] I have read the FAQ and my problem is not listed.
Tell us about your environment
- ESLint version: 7.2.0
- eslint-plugin-vue version: 7.5.0
- Node version: v10.16.3
- Operating System: windows10
Please show your full configuration:
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"globals": {
"BMap": true
},
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "babel-eslint",
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"generators": false,
"objectLiteralDuplicateProperties": false
}
},
"plugins": ["import", "vue"],
"rules": {
"vue/require-valid-default-prop": ["error"]
}
}
What did you do?
export default {
name: 'Settings',
props: {
a: {
type: Object,
default() {},
},
b: {
type: Object,
default: () => {},
},
c: {
type: Object,
default: () => undefined,
},
d: {
type: Object,
default: () => false,
},
},
}
What did you expect to happen?
error: Type of the default value for 'a' prop must be a object (vue/require-valid-default-prop) error: Type of the default value for 'b' prop must be a object (vue/require-valid-default-prop) error: Type of the default value for 'c' prop must be a object (vue/require-valid-default-prop) error: Type of the default value for 'd' prop must be a object (vue/require-valid-default-prop)
What actually happened?
error: Type of the default value for 'd' prop must be a object (vue/require-valid-default-prop)
Repository to reproduce this issue
Thank you for this issue.
I think we need to add another rule to check for the existence of return
. It's similar to vue/return-in-computed-property rule.
@ota-meshi
Hi
And what should I do with the next?
@ota-meshi Hi And what should I do with the next?
change query type
to Array
. Also, the default value of settings
should be ({})
instead of {}
.
change
query type
toArray
. Also, the default value ofsettings
should be({})
instead of{}
.
Totally missed that thank you so much