Skip to content

Rule proposal: Restrict function props #2283

Open
@ECrownofFire

Description

@ECrownofFire

Please describe what the rule should do:

Restrict using functions as props and encourage using events instead.

Options for exceptions could be useful for cases such as sorting or formatting (e.g. with a name pattern/regex). In TypeScript it could be useful to allow non-void functions.

What category should the rule belong to?

  • Enforces code style (layout)
  • 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:

// <script setup>
defineProps<{
  func: () => void;
}>();

defineProps({
  func: Function,
});

Additional context
Some code styles consider passing functions as props, particularly void functions, an anti-pattern in Vue.

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