Skip to content

no-lone-template

Reports a nested <template> that has no directive (v-if, v-for, v-slot, …). Only in .vue files.

A <template> with no directive is a wrapper that Vue renders without its own element, so it does nothing and only adds a level.

To fix, remove the tag and keep its content, or add the directive that was meant.

Reported
<template>
<div>
<template><p>lone</p></template>
<template v-if="a"><p>ok</p></template>
<template #head><p>ok</p></template>
...
angular:
lint:
rules:
no-lone-template: warn # off, warn (default), error
html:
lint:
rules:
no-lone-template: warn # off, warn (default), error
svelte:
lint:
rules:
no-lone-template: warn # off, warn (default), error
vue:
lint:
rules:
no-lone-template: warn # off, warn (default), error

Enabled by the presets: html/eslint-plugin-vue-recommended.

Suppress one line with sudsy-disable-next-line no-lone-template in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint-plugin-vue no-lone-template full