Vize

vue/html-self-closing

Enforce self-closing style.

Default severity Presets Automatic fix Options
warning nuxt, opinionated Yes Rule options

Applies to: Vue SFC templates and blocks, with script context where the rule requires it.

Bad

The empty component and normal div use closing pairs instead of the configured self-closing spelling.

<template>
  <section>
    <MyComponent></MyComponent>
    <div></div>
  </section>
</template>

Good

Empty components and normal elements use self-closing syntax, while void elements omit the slash and an element with content retains its closing tag.

<template>
  <section>
    <MyComponent />
    <div />
    <img>
    <br>
    <div>content</div>
  </section>
</template>

Configuration (Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/html-self-closing": "warn"
    }
  },
});

Then run vp run lint.