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 Proposal: Maximum number of props #2429

Closed
kevsommer opened this issue Mar 15, 2024 · 0 comments · Fixed by #2430
Closed

Rule Proposal: Maximum number of props #2429

kevsommer opened this issue Mar 15, 2024 · 0 comments · Fixed by #2430

Comments

@kevsommer
Copy link
Contributor

Please describe what the rule should do:
The rule should allow developers to set a maximum number of props for Vue components in a project.
In my personal experience a high of number of props correlates strongly with complexity of a component.
Therfore, I think it would be a good addition to the vue eslint rule set, to give developers the option to enforce this rule.

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:

<!-- BAD with maxProps set to 5 -->
<script setup>
defineProps({ 
  prop1: String,
  prop2: String,
  prop3: String,
  prop4: String,
  prop5: String,
  prop6: String,
  prop7: String,
  prop8: String,
})
</script>
<!-- GOOD with maxProps set to 5 -->
<script setup>
defineProps({ 
  prop1: String,
  prop2: String,
  prop3: String,
})
</script>

Additional context
So far I haven't found a similar rule proposal.
But given the ruleset includes the vue/max-len rule, which similarly helps control the complexity of components, I think it would be a good addition.

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.

2 participants