Skip to content

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

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

Closed
HerringtonDarkholme opened this issue Jun 21, 2017 · 1 comment
Closed

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

HerringtonDarkholme opened this issue Jun 21, 2017 · 1 comment

Comments

@HerringtonDarkholme
Copy link
Member

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>
@mysticatea
Copy link
Member

Thank you for the report.

I have not known that <template>s allow empty.
In that case, it's false positive.

mysticatea added a commit that referenced this issue Jun 22, 2017
@michalsnik michalsnik added this to the Official release milestone Jun 26, 2017
michalsnik pushed a commit that referenced this issue Jun 27, 2017
…tes (fixes #41) (#44)

* Fix: `no-invalid-template-root` has false positive about empty templates (fixes #41)

* revive warnings of empty

* update docs

* fix for src attributes

* fix error message

* `if` → `in`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants