Skip to content

Rule Proposal: Maximum number of props  #2429

@kevsommer

Description

@kevsommer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy