Skip to content

no-props-default-factory-undefined #2353

Open
@fisker

Description

@fisker

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions