Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

html-validate-vue

html-validate14.4kMIT7.2.2

vue transform for html-validate

html, lint, html-validate, vue

readme

html-validate-vue

Vue.js plugin for HTML-Validate.

  • Transforms single file components and template strings.
  • Augments element metadata for usage with components.
  • Definitions for <slot> and <transition> elements.
  • Additional rules.

Usage

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

In .htmlvalidate.json:

{
  "plugins": ["html-validate-vue"],
  "extends": ["html-validate:recommended", "html-validate-vue:recommended"],
  "elements": ["html5"],
  "transform": {
    "^.*\\.vue$": "html-validate-vue"
  }
}

The default is to internally autodetect what transforms to apply based on filename. For normal usage this is usually ok but it can be explicitly set by using one of these named transforms:

  • html-validate-vue:auto: best match based on filename (default). *.vue uses sfc, *.{jsx?,tsx?} uses js and other files uses html to apply hooks only.
  • html-validate-vue:js: transform a javascript file by looking for objects with a template property.
  • html-validate-vue:html: transform a html file (only applying hooks).
  • html-validate-vue:sfc: transform a single-file component.

Vue CLI

If you're using Vue CLI you can add the CLI plugin:

vue add html-validate
vue-cli-service html-validate

Supported elements

  • <component>
  • <keep-alive>
  • <router-link>
  • <router-view>
  • <slot>
  • <transition>

Rules

Rule Recommended Description
vue/available-slots Error Validate usage of slots. Only known slots may be used.
vue/prefer-slot-shorthand Error Prefers the usage of #foo over v-slot:foo.
vue/required-slots Error Validate required slots. Required slots must be used.

Element metadata

Property Datatype Description
component string Component uses <component is=".."> to wrap content
slots string[] List of available slots.
requiredSlots string[] List of required slots.

Slots

Components with slots can add element metadata for the slot using ${component}:${slot} syntax, e.g my-component:my-slot.

Given a component like this:

<template>
  <div>
    <div class="my-component-heading">
      <slot name="heading"></slot>
    </div>
    <div class="my-component-body">
      <slot name="body"></slot>
    </div>
    <div class="my-component-footer">
      <slot name="footer"></slot>
    </div>
  </div>
</template>

Metadata for the component itself is written as normally:

{
  "my-component": {
    "flow": true,
    "slots": ["heading", "body", "footer"],
    "requiredSlots": ["body"]
  }
}

Metadata for the slots is written as normally with the exception of the keys. Each key is prefixed with its parent/component and delimited by # and ending with its slot name:

{
  "my-component#heading": {
    "permittedDescendants": ["@heading"]
  },
  "my-component#body": {
    "permittedContent": ["@flow"]
  },
  "my-component#footer": {
    "permittedContent": ["@phrasing"]
  }
}

# is used as a delimiter due to it being the official shorthand for slots in Vue.

Note: unless the default slot is wrapped in v-slot:default it will not be validated by my-component#default but by the component element itself. This can be miltigated by adding default as a required slot.

Dynamic components

If your component uses <component is=".."> to dynamically select element the component property marks which attribute selects the tagname.

<template>
  <div>
    <component :is="tagname">
      <slot></slot>
    </component>
  </div>
</template>

<script>
Vue.component("my-component", {
  props: ["tagname"],
});
</script>

The corresponding metadata would look like this:

{
  "my-component": {
    "component": "tagname"
  }
}

Using this the following markup would yield an error:

<my-component tagname="label">
  <div>A div cannot be inside a label</div>
</my-component>

When using named slots the component property goes directly onto the slot metadata:

{
  "my-component#default": {
    "component": "tagname"
  }
}

The attribute is always read from the component itself, not the slot <template> element:

<my-component tagname="label">
  <template v-slot:default>...</template>
</my-component>

changelog

html-validate-vue changelog

7.2.2 (2025-06-16)

Bug Fixes

  • fix <template> element with recent html-validate (e530cf7)

7.2.1 (2025-05-25)

Bug Fixes

  • retain sfc <template> element to allow metadata to specify <template> as ancestor (e00d9b1)

7.2.0 (2025-05-25)

Features

  • handle when sfc <template> tag is indented (fbc3ff0)

7.1.6 (2025-05-18)

Bug Fixes

  • deps: update dependency semver to v7.7.2 (747daa2)

7.1.5 (2025-02-09)

Bug Fixes

  • deps: update dependency semver to v7.7.1 (50c310f)

7.1.4 (2025-02-02)

Bug Fixes

  • deps: update dependency semver to v7.7.0 (fa28ab1)

7.1.3 (2024-12-29)

Bug Fixes

  • deps: pin dependency @html-validate/plugin-utils to 2.0.3 (b95382c)

7.1.2 (2024-12-23)

Bug Fixes

  • deps: update @html-validate/plugin-utils to v2.0.3 (6a371c0)

7.1.1 (2024-12-22)

Bug Fixes

  • deps: pin dependency @html-validate/plugin-utils to 2.0.2 (73971c3)

7.1.0 (2024-12-21)

Features

7.0.0 (2024-12-15)

⚠BREAKING CHANGES

  • deps: require nodejs v18 or later
  • deps: require html-validate v8 or later

Features

  • deps: require html-validate v8 or later (a7874ae)
  • deps: require nodejs v18 or later (7135759)
  • deps: support html-validate v9 (9109405)
  • deps: update dependency @html-validate/plugin-utils to v2 (741fc4c)

6.2.0 (2024-11-24)

Features

  • remove usage of filesystem (node:fs) (b262c3a)

6.1.0 (2024-09-24)

Features

  • handle same-name prop shorthand (7764d1e)

6.0.8 (2024-07-21)

Bug Fixes

  • deps: update dependency semver to v7.6.3 (36f8d71)

6.0.7 (2024-05-12)

Bug Fixes

  • deps: update dependency semver to v7.6.1 (8d4b631)
  • deps: update dependency semver to v7.6.2 (b2bf989)

6.0.6 (2024-04-05)

Bug Fixes

  • router-view: allow content under <router-view> (c11b3cc), closes #12

6.0.5 (2024-2-11)

Bug Fixes

  • deps: update dependency semver to v7.6.0 (1d88ead)

6.0.4 (2023-07-16)

Bug Fixes

  • drop support for deprecated void rule (e3a4cc6)

6.0.3 (2023-07-09)

Dependency upgrades

  • deps: update dependency semver to v7.5.4 (e801c80)

6.0.2 (2023-06-25)

Dependency upgrades

  • deps: update dependency semver to v7.5.3 (a3c655d)

6.0.1 (2023-06-18)

Dependency upgrades

  • deps: update dependency semver to v7.5.2 (46a2d9f)

6.0.0 (2023-06-04)

⚠BREAKING CHANGES

  • deps: require html-validate v5 or later
  • deps: require nodejs v16 or later

Features

  • deps: require html-validate v5 or later (3423114)
  • deps: require nodejs v16 or later (0ab86ce)

Dependency upgrades

  • deps: pin dependency @html-validate/plugin-utils to 1.0.1 (2a9da0a)
  • deps: support html-validate v8 (b4f17a8)
  • deps: support html-validate v8 (8abf789)
  • deps: update dependency @html-validate/plugin-utils to v1.0.2 (e9cb34e)

5.1.4 (2023-05-14)

Dependency upgrades

  • deps: update dependency semver to v7.5.1 (de19fa6)

5.1.3 (2023-04-23)

Dependency upgrades

  • deps: update dependency semver to v7.5.0 (e4718d4)

5.1.2 (2023-04-16)

Dependency upgrades

  • deps: update dependency semver to v7.4.0 (d796154)

5.1.1 (2022-10-09)

Dependency upgrades

  • deps: update dependency semver to v7.3.8 (bd161c7)

5.1.0 (2022-05-23)

Features

5.0.0 (2022-05-08)

⚠BREAKING CHANGES

  • require node 14

Features

Dependency upgrades

  • deps: support html-validate v7 (53883ae)

4.3.0 (2022-05-08)

Features

  • require html-validate v4.14 or later (58de4db)

4.2.4 (2022-04-23)

Bug Fixes

  • fix semver dependency being extraneous pulled in as dependency (7489397)

4.2.3 (2022-04-17)

Dependency upgrades

  • deps: update dependency semver to v7.3.7 (324e59f)

4.2.2 (2022-04-10)

Dependency upgrades

  • deps: update dependency semver to v7.3.6 (8d97ffd)

4.2.1 (2022-03-20)

Bug Fixes

  • ignore dynamic slots in prefer-slot-shorthand (903eebc)

4.2.0 (2022-02-20)

Features

  • new rule prefer-slot-shorthand (c67fbc4), closes #7

4.1.0 (2022-02-20)

Features

Dependency upgrades

  • deps: pin dependency semver to 7.3.5 (91ba594)

4.0.3 (2022-02-05)

Bug Fixes

  • html-validate v6.1 compatibility (9344375)

4.0.2 (2021-09-27)

Dependency upgrades

  • deps: update dependency html-validate to v6 (fd33619)

4.0.1 (2021-06-27)

Dependency upgrades

  • deps: update dependency html-validate to v5 (1ca7122)

4.0.0 (2021-06-27)

⚠BREAKING CHANGES

  • require NodeJS 12

Features

3.2.1 (2021-03-21)

Dependency upgrades

  • deps: accept any v7 version of semver (c2a3462)

3.2.0 (2020-11-08)

Features

Bug Fixes

  • bump peerDependency and engines requirements (4a98cdb)
  • migrate to dist folder (d64e467)

3.1.2 (2020-11-01)

3.1.1 (2020-10-25)

3.1.0 (2020-04-05)

Features

3.0.3 (2020-03-29)

3.0.2 (2020-02-17)

Bug Fixes

  • config: use new void rules (c622cbc)

3.0.1 (2020-02-12)

Bug Fixes

  • fix <component> not being allowed anywhere (20a1eba)

3.0.0 (2020-02-09)

Features

  • change to named transform (dcd0c9b)
  • drop html-validate@1 compatibility (3ee6d6a)
  • expose auto as more explicit autodetection transformer (facd6df)
  • expose html transform to apply hooks only (ff476c4)
  • expose js and sfc as named transformers (c14536b)

BREAKING CHANGES

  • Previously it was possible to load this as a regular transformer using html-validate 1 but the peerDependency has required version 2 for a while. The plugin also includes a runtime check for version 2. All uses must now update to html-validate 2 and load this as a plugin.

2.6.0 (2020-02-05)

Features

2.5.1 (2020-01-26)

Bug Fixes

  • deps: update dependency html-validate to v2.11.0 (ee854bb)

2.5.0 (2020-01-21)

Features

  • elements: support <keep-alive> (7c6520b)
  • elements: support <router-link> and <router-view> (d1d3bf6)

2.4.0 (2020-01-15)

Features

2.3.4 (2019-12-27)

2.3.3 (2019-12-27)

2.3.2 (2019-12-27)

2.3.1 (2019-12-27)

Bug Fixes

2.3.0 (2019-12-16)

Features

2.2.1 (2019-12-08)

Bug Fixes

  • add preamble length to offset (239e0a7)

2.2.0 (2019-12-02)

Features

2.1.0 (2019-11-30)

Features

  • reconfigure attr-case by default (f5da29c)

2.0.1 (2019-11-28)

Bug Fixes

  • handle slots with dashes (b3fa646)

2.0.0 (2019-11-24)

Features

  • add .htmlvalidate.json for easier testing during dev (80bea40)
  • add recommended config (a476f4c)
  • add required-slots rule (9e8a100)
  • convert to plugin (fc380e1)
  • validate available slots (c69a0e4)

BREAKING CHANGES

  • the plugin must be included using plugin: ["html-validate-vue"] and not just as a transformer.

1.4.0 (2019-11-17)

Features

1.3.2 (2019-11-13)

Bug Fixes

  • add <transition> element (74b8f3a), closes #2

1.3.1 (2019-10-08)

Bug Fixes

  • transform: handle v-html and <slot> as dynamic text (16d5ac7), closes #1

1.3.0 (2019-09-23)

Features

  • elements: add elements.json with <slot> declaration (03025da)

1.2.0 (2019-02-24)

  • Improved attribute handling
  • Rewritten in typescript

1.1.0 (2019-02-19)

  • Handle :foo and v-bind:foo as dynamic attributes.
  • Bump dependencies

1.0.7 (2019-02-19)

  • Migrate project to gitlab.com

1.0.6 (2018-12-16)

  • Bump html-validate to 0.16.1

1.0.5 (2018-11-07)

  • Bump html-vlidate to 0.14.2