Back to Biomejs

useVueValidTemplateRoot

src/content/docs/linter/rules/use-vue-valid-template-root.mdx

latest1.9 KB
Original Source

import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs> <TabItem label="HTML" icon="seti:html"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.11` - Diagnostic Category: [`lint/nursery/useVueValidTemplateRoot`](/reference/diagnostics#diagnostic-category) - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - This rule belongs to the following domains: - [`vue`](/linter/domains#vue) - Sources: - Same as [`vue/valid-template-root`](https://eslint.vuejs.org/rules/valid-template-root)

How to configure

json
{
	"linter": {
		"rules": {
			"nursery": {
				"useVueValidTemplateRoot": "error"
			}
		}
	}
}

Description

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.

Examples

Invalid

vue
<template src="./foo.html">content</template>
<pre class="language-text"><code class="language-text"></code></pre>
vue
<template></template>
<pre class="language-text"><code class="language-text"></code></pre>

Valid

vue
<template>content</template>
vue
<template src="./foo.html"></template>
</TabItem> </Tabs>