Skip to content

define-model-declaration #3069

@dword-design

Description

@dword-design

Please describe what the rule should do:

Analogous to define-props-declaration, there should be a rule define-model-declaration that enforces a type-based declaration.

What category should the rule belong to?

[x] 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 lang="ts">
defineModel();
</script>
<script setup lang="ts">
defineModel({ type: String });
</script>

Workaround

'no-restricted-syntax': [
  'error',
  {
    message:
      'defineModel() must use an explicit type parameter, e.g. defineModel<string>().',
    selector:
      "CallExpression[callee.name='defineModel']:not([typeArguments]):not([typeParameters])",
  },
],

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