Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 1.16 KB

valid-template-root.md

File metadata and controls

64 lines (49 loc) · 1.16 KB

Enforce valid template root (valid-root-element)

This rule checks whether every template root is valid.

📖 Rule Details

This rule reports the template root in the following cases:

  • The root is nothing. E.g. <template></template>.
  • The root is text. E.g. <template>hello</template>.
  • The root is multiple elements. E.g. <template><div>one</div><div>two</div></template>.
  • The root element has v-for directives. E.g. <template><div v-for="x in list">{{x}}</div></template>.
  • The root element is <template> or <slot> elements. E.g. <template><template>hello</template></template>.

👎 Examples of incorrect code for this rule:

<template>
</template>
<template>
    <div>hello</div>
    <div>hello</div>
</template>
<template>
    abc
</template>
<template>
    <div v-for="x in list"></div>
</template>

👍 Examples of correct code for this rule:

<template>
    <div>abc</div>
</template>
<template>
    <div v-if="foo"></div>
</template>
<template>
    <div v-if="foo">abc</div>
    <div v-else>def</div>
</template>

🔧 Options

Nothing.