Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork688
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
base:master
Are you sure you want to change the base?
implements autofix in define-props-declaration (#2465)#2466
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ased syntax (vuejs#2465)handle native types (String, Boolean etc.)
…ased syntax (vuejs#2465)handle PropTypes (e.g. String as PropType<'test'>)
…ased syntax (vuejs#2465)handle required option
…ased syntax (vuejs#2465)handle default option
…ased syntax (vuejs#2465)handle separateInterface rule option
…ased syntax (vuejs#2465)bring back the runtime check
…ased syntax (vuejs#2465)additional tests and refactoring
…ased syntax (vuejs#2465)documentation update
…ased syntax (vuejs#2465)fix tests failing on some environments
…ased syntax (vuejs#2465)handle array of types
…ased syntax (vuejs#2465)refactoring
…ased syntax (vuejs#2465)copy type for unknown expressions, ignore fixing cases when error is thrown
…ased syntax (vuejs#2465)handle union type
@FloEdelmann can I get some attention to this PR? |
There was a problem hiding this 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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Flo Edelmann <git@flo-edelmann.de>
28aab32
to7d9e731
Compare@FloEdelmann applied changes, please review again |
There was a problem hiding this 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?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@ota-meshi Could you please clear the Netlify cache and restart the deployment? That would make the rule (and docs) changes easier to test. |
I cleared the cache and restart. The PR status remains failed, but it seems to have worked. |
There was a problem hiding this 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!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
9cca135
toe9d4400
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Should we fix it to multi-line interface, then make the separator configurable? |
No, let's keep it single-line and leave the rest to other ESLint rules or formatters like Prettier. |
Uh oh!
There was an error while loading.Please reload this page.
*/ | ||
function getComponentPropData(prop, sourceCode) { | ||
if (prop.propName === null) { | ||
throw new Error('Unexpected prop with null name.') |
There was a problem hiding this comment.
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?
mpiniarskiJul 15, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
@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.`) |
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading.Please reload this page.
Fixes#2465