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

Appearance settings

Rule Proposal: Maximum number of props  #2429

Copy link
Copy link
Closed
@kevsommer

Description

@kevsommer
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.