Skip to content

Add autofix to define-props-declaration: transform runtime syntax to type-based syntax #2465

Open
@mpiniarski

Description

@mpiniarski

What rule do you want to change?
define-props-declaration
Does this change cause the rule to produce more or fewer warnings?
Does not change the number of warnings.
How will the change be implemented? (New option, new default behavior, etc.)?
Implementing a fix method in the context.report descriptor parameter.

The rule will support separateInterface option that will opt-in to define type passed to the defineProps as an interface above defineProps call.

Please provide some example code that this change will affect:
The rule will be able to autofix the following code:

      <script setup lang="ts">
      const props = defineProps({
        kind: String
      })
      </script>

transforming it to:

      <script setup lang="ts">
      const props = defineProps<{ kind: string }>()
      </script>

What does the rule currently do for this code?
It des not fix it.

What will the rule do after it's changed?
The rule will have the autofix feature transforming runtime syntax to type-based syntax
Additional context

Activity

FloEdelmann

FloEdelmann commented on May 27, 2024

@FloEdelmann
Member

PR welcome, but note that the autofix would need to handle quite complex cases like transforming { foo: String as PropType<'a' | 'b'>, bar: User, baz: Number } to { foo: 'a' | 'b'; bar: User; baz: number }.

mpiniarski

mpiniarski commented on May 27, 2024

@mpiniarski
Author

Pull request created #2466

5 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @FloEdelmann@mpiniarski@zernonia

      Issue actions

        Add autofix to `define-props-declaration`: transform runtime syntax to type-based syntax · Issue #2465 · vuejs/eslint-plugin-vue