Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

implements autofix in define-props-declaration (#2465)#2466

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mpiniarski wants to merge28 commits intovuejs:master
base:master
Choose a base branch
Loading
frommpiniarski:feature/#2465_autofix_in_define-props-declaration

Conversation

mpiniarski
Copy link

@mpiniarskimpiniarski commentedMay 27, 2024
edited by FloEdelmann
Loading

Fixes#2465

…ased syntax (vuejs#2465)handle native types (String, Boolean etc.)
…ased syntax (vuejs#2465)handle PropTypes (e.g. String as PropType<'test'>)
@mpiniarski
Copy link
Author

@FloEdelmann can I get some attention to this PR?

Copy link
Member

@FloEdelmannFloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for the ping! I had an initial look now.

@mpiniarskimpiniarskiforce-pushed thefeature/#2465_autofix_in_define-props-declaration branch from28aab32 to7d9e731CompareJune 21, 2024 13:07
@mpiniarski
Copy link
Author

@FloEdelmann applied changes, please review again

Copy link
Member

@ota-meshiota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for working on that implementation!

It seems to be causing an error in CI. Could you please fix that as well?

@FloEdelmann
Copy link
Member

@ota-meshi Could you please clear the Netlify cache and restart the deployment? That would make the rule (and docs) changes easier to test.

@ota-meshi
Copy link
Member

I cleared the cache and restart. The PR status remains failed, but it seems to have worked.
https://deploy-preview-2466--eslint-plugin-vue.netlify.app/rules/define-props-declaration.html

FloEdelmann reacted with thumbs up emoji

Copy link
Member

@FloEdelmannFloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Some more small JSDoc suggestions, then this is good to go from my side! Thanks for the contribution!

@mpiniarskimpiniarskiforce-pushed thefeature/#2465_autofix_in_define-props-declaration branch from9cca135 toe9d4400CompareJuly 4, 2024 07:38
@so1ve
Copy link
Member

Should we fix it to multi-line interface, then make the separator configurable?

@FloEdelmann
Copy link
Member

No, let's keep it single-line and leave the rest to other ESLint rules or formatters like Prettier.

so1ve reacted with thumbs up emoji

*/
function getComponentPropData(prop, sourceCode) {
if (prop.propName === null) {
throw new Error('Unexpected prop with null name.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why does it need to throw an error here?
Can't we make it guard against those before processing the autofix?

Copy link
Author

@mpiniarskimpiniarskiJul 15, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What do you mean?
I think it's more clear if we throw an error here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think that if we throw an error, the user's eslint command will fail.
Did you throw the error with that intention? If so, why is that?
If auto-fix is not possible, I think it should be handled so that auto-fix is not performed, rather than throwing an error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I see. Let me catch errors and ignore them.

I prefer to leave a sign of an error somewhere, maybe inconsole.debug(), but it is up to you.

filename: 'test.vue',
code: `
<script setup lang="ts">
const props = defineProps([kind])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The array elements must be strings. Thekind variable shouldn't auto-fix because we don't know what's actually in it.
Could you leave this test as a test case for when not to auto-fix and add a new test case using a string literal?

https://vuejs.org/guide/components/props.html#props-declaration

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

My bad, you're right. It does not default to astring. Leaving it unhandled then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could you please add the test case you requested earlier?

      <script setup lang="ts">const props=defineProps(['kind'])</script>

#2466 (comment)

@mpiniarski
Copy link
Author

@ota-meshi can you take a look?

*/
function getComponentPropData(prop, sourceCode) {
if (prop.type === 'array') {
throw new Error(`Unable to resolve types based on array prop declaration.`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could you please implement it so that the autofix stops without throwing an error?

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

@FloEdelmannFloEdelmannFloEdelmann approved these changes

@ota-meshiota-meshiota-meshi requested changes

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add autofix todefine-props-declaration: transform runtime syntax to type-based syntax
4 participants
@mpiniarski@FloEdelmann@ota-meshi@so1ve

[8]ページ先頭

©2009-2025 Movatter.jp