eslint-plugin-vue
eslint-plugin-vue copied to clipboard
`no-props-default-factory-undefined`
Please describe what the rule should do:
Disallow () => {}
as the default of props.
What category should the rule belong to?
[ ] Enforces code style (layout) [x] Warns about a potential error (problem) [ ] Suggests an alternate way of doing something (suggestion) [ ] Other (please specify:)
Provide 2-3 code examples that this rule should warn about:
defineProps({
foo: {
default: () => {},
},
});
probably mean to use the following, but forgot parentheses
defineProps({
foo: {
default: () => ({}),
},
});
Additional context
In most cases, it's just a mistake to return an empty object. If mean to default to undefined
,
defineProps({foo: {default: undefined}});
OR
defineProps({foo: {default: () => undefined}}); // Maybe also forbid this? The above should be preferred.
should be used.
Consider using https://eslint.org/docs/latest/rules/no-empty-function