vue/permitted-contents
Enforce HTML content model rules.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
happy-path, nuxt, ecosystem, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The examples put block content in p, omit the table body, nest interactive controls, or put a div directly inside ul.
<template>
<p><div>block in a paragraph</div></p>
<table><tr><td>row without tbody</td></tr></table>
<a href="#"><button type="button">nested control</button></a>
<ul><div>not a list item</div></ul>
</template>
Good
The examples use inline paragraph content, an explicit tbody, and li children. The custom MyItem is not treated as a known native ul child.
<template>
<p><span>inline in a paragraph</span></p>
<table><tbody><tr><td>cell</td></tr></tbody></table>
<ul><li>list item</li><MyItem /></ul>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/permitted-contents": "error"
}
},
});
Then run vp run lint.