Skip to content

Rule proposal: require-emit-validator #1482

Closed
@g-plane

Description

@g-plane

Please describe what the rule should do:

Enforce detailed emits option with types.

What category should the rule belong to?

[ ] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[x] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

// bad
export default defineComponent({
  emits: ['update'],
})

// good
export default defineComponent({
  emits: {
    update: (payload: Payload) => typeof payload === 'object',
  },
})

Additional context

  • Declaring types of emits can provide better TypeScript inference.
  • This rule is similar to require-prop-types.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions