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

Rule suggestion: vue/require-explicit-slots to require all slots to be documented #2294

Closed
Amixx opened this issue Oct 11, 2023 · 3 comments · Fixed by #2325
Closed

Rule suggestion: vue/require-explicit-slots to require all slots to be documented #2294

Amixx opened this issue Oct 11, 2023 · 3 comments · Fixed by #2325

Comments

@Amixx
Copy link

Amixx commented Oct 11, 2023

Please describe what the rule should do:
I would like a rule that requires defineSlots to be present if there are any slots in the component - could be called vue/no-undeclated-slots or something similar. I did not find a rule that does this in the rule list, and did not find a relevant issue.

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:

<template>
<slot></slot>
</template>

<script setup lang="ts">
// any code, except `defineSlots`
</script>

Additional context
I am sorry if this issue is not submitted correctly, and will fix any errors. I am also willing to try to implement the rule myself if anyone can give me a starting point (maybe a rule that is somewhat similar)

@FloEdelmann
Copy link
Member

Sounds good!

For reference, here is the documentation of defineSlots: https://vuejs.org/api/sfc-script-setup.html#defineslots
That should also be included in the rule documentation.

Similar rules:

As a name for the new rule, I'd suggest vue/require-explicit-slots to be consistent with vue/require-explicit-emits.

@FloEdelmann FloEdelmann changed the title A rule that would require all slots to be documented Rule suggestion: vue/require-explicit-slots to require all slots to be documented Oct 11, 2023
@Amixx
Copy link
Author

Amixx commented Oct 12, 2023

Thanks for the quick comment, I will try to implement it over the weekend.

@mussinbenarbia
Copy link
Contributor

@Amixx @FloEdelmann I noticed that there was no PR for this yet so I gave this a try here 🙇 I hope it's ok

@FloEdelmann FloEdelmann linked a pull request Nov 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants