Closed
Description
Tell us about your environment
- ESLint Version: 4.13.0
- eslint-plugin-vue Version: 4.0.0-beta.2
- Node Version: 8.6.0
Please show your full configuration:
Here's a minimal repro: https://github.com/austindebruyn/eslintvuespread-repro
module.exports = {
extends: [
// add more generic rulesets here, such as:
// 'eslint:recommended',
'plugin:vue/essential',
'plugin:vue/strongly-recommended'
],
rules: {
// override/add rules settings here, such as:
// 'vue/no-unused-vars': 'error'
}
}
What did you do? Please include the actual source code causing the issue.
Including a spread operator inside your prop delcaration makes the require-default-prop
rule crash.
export default {
name: 'TheComponent',
props: {
size: {
type: String,
...oneOf(['sm', 'md', 'lg']),
default: 'sm'
}
}
};
What did you expect to happen?
Not crash
What actually happened? Please include the actual, raw output from ESLint.
Looks like the check here is a little too trusting.
I can open a fix, but I'm also not sure what the recommended behavior is. What I was trying to do (spread inside the prop) was a little wacky and I changed it, but eslint probably shouldn't just crash.
austin@oswald:~/projects/eslint-vue-spread-breaks$ ./node_modules/.bin/eslint test.jsx
Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
at prop.value.properties.find.p (/home/austin/projects/eslint-vue-spread-breaks/node_modules/eslint-plugin-vue/lib/rules/require-default-prop.js:52:25)
at Array.find (native)
at propHasDefault (/home/austin/projects/eslint-vue-spread-breaks/node_modules/eslint-plugin-vue/lib/rules/require-default-prop.js:52:10)
at propsNode.value.properties.filter.filter.prop (/home/austin/projects/eslint-vue-spread-breaks/node_modules/eslint-plugin-vue/lib/rules/require-default-prop.js:70:44)
at Array.filter (<anonymous>)
at findPropsWithoutDefaultValue (/home/austin/projects/eslint-vue-spread-breaks/node_modules/eslint-plugin-vue/lib/rules/require-default-prop.js:65:10)
at utils.executeOnVue (/home/austin/projects/eslint-vue-spread-breaks/node_modules/eslint-plugin-vue/lib/rules/require-default-prop.js:89:35)
at ExportDefaultDeclaration:exit (/home/austin/projects/eslint-vue-spread-breaks/node_modules/eslint-plugin-vue/lib/utils/index.js:467:9)
at listeners.(anonymous function).forEach.listener (/home/austin/projects/eslint-vue-spread-breaks/node_modules/eslint/lib/util/safe-emitter.js:47:58)
at Array.forEach (<anonymous>)