Skip to content

Suggestion: relax invalid-template-root for v-if #41

Closed
@HerringtonDarkholme

Description

@HerringtonDarkholme

Tell us about your environment

  • ESLint Version: 4.0.0
  • eslint-plugin-vue Version: 3.1.2
  • Node Version: 8.0.0

Conditionally empty template root can be acceptable. For example, in a list item component, if an item is empty/undefined, empty template root represents skipping render.

The reason behind it is that we can encapsulate null check in the component, so we can pass empty value to the component.

vue-hackernews also employs such strategy.
https://github.com/vuejs/vue-hackernews-2.0/blob/master/src/components/Comment.vue#L2

<template>
  <li v-if="comment" class="comment">
  </li>
</template>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions