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

Maximum depth of template block #2524

Closed
kevsommer opened this issue Aug 12, 2024 · 0 comments · Fixed by #2525
Closed

Maximum depth of template block #2524

kevsommer opened this issue Aug 12, 2024 · 0 comments · Fixed by #2525

Comments

@kevsommer
Copy link
Contributor

Please describe what the rule should do:
The rule should allow developers to set a maximum depth for templates for Vue components in a project.
In my experience a high depth of a template correlates with very complex components, so forcing a developer to split up a component into subcomponents via an optional linting rule, could aid in keeping complexity down in a codebase.
Therefore, 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 -->
<template>
  <main-container>
    <child-component>
      <div />
    </child-component>
    <child-component>
      <nested-component>
        <div>
          <div />
        </div>
      </nested-component>
    </child-component>
  </main-container>
</template>
<!-- ✓ GOOD -->
<template>
  <main-container>
    <child-component>
      <div />
    </child-component>
  </main-container>
</template>

Additional context
So far I haven't found a similar rule proposal.
But given the ruleset includes the vue/max-len rule and vue/max-props, which similarly help 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