eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

`no-props-default-factory-undefined`

Open fisker opened this issue 1 year ago • 1 comments

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.

fisker avatar Dec 21 '23 04:12 fisker

Consider using https://eslint.org/docs/latest/rules/no-empty-function

jacekkarczmarczyk avatar Dec 21 '23 04:12 jacekkarczmarczyk