Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mpiniarski opened this issue May 27, 2024 · 3 comments · May be fixed by #2466
Open

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

mpiniarski opened this issue May 27, 2024 · 3 comments · May be fixed by #2466

Comments

@mpiniarski
Copy link

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

@FloEdelmann
Copy link
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 added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
…ased syntax (vuejs#2465)

handle native types (String, Boolean etc.)
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
…ased syntax (vuejs#2465)

handle PropTypes (e.g. String as PropType<'test'>)
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
…ased syntax (vuejs#2465)

handle separateInterface rule option
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
@mpiniarski
Copy link
Author

Pull request created #2466

mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 27, 2024
…ased syntax (vuejs#2465)

fix tests failing on some environments
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 28, 2024
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 28, 2024
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 28, 2024
…ased syntax (vuejs#2465)

copy type for unknown expressions, ignore fixing cases when error is thrown
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue May 28, 2024
@zernonia
Copy link

zernonia commented May 29, 2024

Was thinking about this transform for this rule when upgrading large project from previous minor Vue version.

mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue Jul 15, 2024
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue Jul 26, 2024
mpiniarski added a commit to mpiniarski/eslint-plugin-vue that referenced this issue Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants