HTML-Validate Vue.js Plugin

8.2.0 · active · verified Sun Apr 19

html-validate-vue is an official plugin for HTML-Validate, designed to extend its robust, offline HTML5 validation capabilities to Vue.js projects. Currently at stable version 8.2.0, the package generally aligns its major releases with html-validate, which typically maintains major versions for about two years, encouraging users to stay updated for critical bug fixes and new features. The plugin seamlessly integrates by transforming Vue Single File Components (SFCs) and raw template strings, ensuring that Vue-specific syntax is correctly parsed and validated. A key differentiator is its ability to augment HTML-Validate's element metadata, enabling component-aware linting for standard Vue components like `<component>`, `<slot>`, `<transition>`, and `<router-link>`, as well as custom user-defined components. It also introduces specialized Vue-centric rules for validating slot usage (e.g., `vue/available-slots`, `vue/required-slots`), promoting best practices and identifying deprecated patterns within Vue templates. This allows for strict and non-forgiving local validation, providing consistent feedback without relying on online services or runtime checks, which is particularly beneficial for maintaining high code quality in component-driven architectures.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the installation of `html-validate` and `html-validate-vue`, and the essential `.htmlvalidate.json` configuration to enable Vue SFC validation in a project.

npm install --save-dev html-validate html-validate-vue

// .htmlvalidate.json
// Place this file in your project root.
{
  "plugins": ["html-validate-vue"],
  "extends": [
    "html-validate:recommended",
    "html-validate-vue:recommended"
  ],
  "elements": ["html5"],
  "transform": {
    "^.*\\.vue$": "html-validate-vue"
  }
}

// Example Vue Single File Component (src/MyComponent.vue)
// This component would be validated by html-validate-vue
// (No actual JavaScript execution here, just demonstrating setup)
/*
<template>
  <section>
    <h1>Welcome</h1>
    <my-button>
      <template #default>
        Click me
      </template>
    </my-button>
  </section>
</template>

<script>
import MyButton from './MyButton.vue';
export default {
  components: { MyButton },
};
</script>

<style scoped>
/* Your styles here */
</style>
*/

view raw JSON →