Skip to content

Overcritical vue/valid-template-root rule? #971

Closed
@sebiniemann

Description

@sebiniemann

Tell us about your environment

  • ESLint version: 6.5.1
  • eslint-plugin-vue version: 5.2.3
  • Node version: 10.16.0

Please show your full configuration:

{
  "env": {
    "browser": true,
    "es6": true,
    "node": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:vue/recommended"
  ],
  "parserOptions": {
    "ecmaVersion": 2019,
    "sourceType": "module"
  },
  "plugins": [
    "vue"
  ]
}

What did you do?

<template>
  <template>
    Hello World
  </template>
</template>

https://mysticatea.github.io/vue-eslint-demo/#eJxVjsEKwjAQRH8l7Lmh4DGIZ+8KXryEZiqBmA2bpFBL/91YEepl4e3bYXahgR3I0LHgmYItON2jUv+k1BkhsLqxBLfpfud3QB1JDchkFpoq+sh64DjW7ONDT3pkadOPZA7d5icbvNO/uBbm0tzakY8OsVz8C9vtF69z+nyakx3QmpKVDGkL5CQArW/g3EXT

My actual use case is something like

<template>
  <template v-if="isValid">
    True
  </template>
  <template v-else>
    False
  </template>
</template>

<script>
export default {
  data() {
    return {
      isValid: false,
    };
  },
};
</script>

where we always use <template> in conjunction with v-for, v-if, ...

https://mysticatea.github.io/vue-eslint-demo/#eJx1kM9KxDAQxl9lmJNCQ8FjXT36Ai576iU0EwnEJEwmxd3Sdzdpu4KIp3y/mW/+ZcEpGsIBT0KfyWuh1zEA/BDMytmXEV2+aO/MiFsa4MyFNmP/bx35TIf7TVf9x/4LKuaJXZKq6StFFjBkdfECS6s0WvTD464BmKRwuBPAsd4Atk3q9vD63N61UlOn/uiPHXLxlHFYcC7Uh6imGGzJLnyoWdnIqh2Nw1O35efWWd1XVRyj1NzaoQuGgry7G23eHc/X1L4zJz1RnZQ0Z+IaoJyYCNdvtNp8aA==

What did you expect to happen?
No error, as Vue compiles without problem.

What actually happened?

[vue/valid-template-root] The template root disallows 'template' elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions