Skip to content

useVueValidTemplateRoot (HTML)

Language HTML
biome.json
{
"linter": {
"rules": {
"correctness": {
"useVueValidTemplateRoot": "error"
}
}
}
}

Enforce valid Vue <template> root usage.

This rule reports only root-level <template> elements. If the <template> has a src attribute, the element must be empty. Otherwise, the element must contain content.

<template src="./foo.html">content</template>
code-block.vue:1:1 lint/correctness/useVueValidTemplateRoot  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The root `<template>` with a src attribute must be empty.

> 1 │ <template src="./foo.html">content</template>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

The src attribute indicates that the content is loaded from an external file.

Remove content when using the src attribute.

Unsafe fix: Remove inline content from `<template>`.

1 │ <template·src="./foo.html">content</template>
-------
<template></template>
code-block.vue:1:1 lint/correctness/useVueValidTemplateRoot ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The root `<template>` is empty.

> 1 │ <template></template>
^^^^^^^^^^^^^^^^^^^^^
2 │

The root `<template>` must contain content when no src attribute is present.

Add content inside the `<template>` or use the src attribute.

<template>content</template>
<template src="./foo.html"></template>