Vize

Vue rules

Correctness, conventions and Vue 3 migration checks for SFC templates, directives, components and blocks.

Each rule page shows a failing example, a passing example, and the configuration that turns the rule on.

Essential (53)

Correctness rules in the essential preset.

Rule What it checks Auto-fix
vue/comment-directive Support comment directives in <template>.
vue/jsx-uses-vars Treat variables used in JSX element names as used.
vue/multi-word-component-names Require component names to be multi-word.
vue/no-child-content Disallow child content when using v-html or v-text.
vue/no-deprecated-filter Disallow deprecated Vue 2 filter syntax using the pipe operator.
vue/no-deprecated-functional-template Disallow the functional attribute on the SFC <template>.
vue/no-deprecated-html-element-is Disallow the is attribute on native HTML elements.
vue/no-deprecated-inline-template Disallow the deprecated inline-template attribute.
vue/no-deprecated-router-link-tag-prop Disallow the tag prop on <router-link>.
vue/no-deprecated-scope-attribute Disallow the deprecated scope attribute on <template>.
vue/no-deprecated-slot-attribute Disallow the deprecated slot attribute.
vue/no-deprecated-slot-scope-attribute Disallow the deprecated slot-scope attribute.
vue/no-deprecated-v-bind-sync Disallow the deprecated .sync modifier on v-bind.
vue/no-deprecated-v-is Disallow the deprecated v-is directive.
vue/no-deprecated-v-on-native-modifier Disallow the deprecated .native modifier on v-on.
vue/no-deprecated-v-on-number-modifiers Disallow deprecated numeric keyCode modifiers on v-on. ✓
vue/no-dupe-v-else-if Disallow duplicate conditions in v-if / v-else-if chains.
vue/no-duplicate-attributes Disallow duplicate attributes on the same element.
vue/no-mutating-props Disallow mutating component props.
vue/no-non-component-keep-alive-child Disallow plain element wrappers directly below <KeepAlive>.
vue/no-reserved-component-names Disallow the use of reserved names as component names.
vue/no-template-key Disallow key attribute on <template>.
vue/no-textarea-mustache Disallow mustache interpolation in <textarea>.
vue/no-unsafe-url Warn about potentially unsafe URL bindings.
vue/no-unused-components Disallow registering components that are not used inside templates.
vue/no-unused-vars Disallow unused variable definitions in v-for and v-slot directives.
vue/no-use-v-if-with-v-for Disallow using v-if on the same element as v-for.
vue/no-useless-template-attributes Disallow useless attributes on <template> elements.
vue/no-v-for-template-key-on-child Disallow key on the child of a <template v-for>.
vue/no-v-html Warn against v-html to prevent XSS vulnerabilities.
vue/no-v-text-v-html-on-component Disallow v-text / v-html on component elements.
vue/require-component-is Require v-bind:is on <component> elements.
vue/require-toggle-inside-transition Require a toggle on the element wrapped by <transition>.
vue/require-v-for-key Require v-bind:key with v-for directives.
vue/use-v-on-exact Enforce .exact modifier on v-on when there are modifier-based handlers.
vue/valid-attribute-name Require valid attribute names.
vue/valid-template-root Enforce a valid <template> root for Vue 3 fragment semantics.
vue/valid-v-bind Enforce valid v-bind directives.
vue/valid-v-cloak Enforce valid v-cloak directives.
vue/valid-v-else Enforce valid v-else directives. ✓
vue/valid-v-else-if Enforce valid v-else-if directives.
vue/valid-v-for Enforce valid v-for directives.
vue/valid-v-html Enforce valid v-html directives.
vue/valid-v-if Enforce valid v-if directives.
vue/valid-v-is Enforce valid v-is directives.
vue/valid-v-memo Enforce valid v-memo directives.
vue/valid-v-model Enforce valid v-model directives.
vue/valid-v-on Enforce valid v-on directives.
vue/valid-v-once Enforce valid v-once directives.
vue/valid-v-pre Enforce valid v-pre directives.
vue/valid-v-show Enforce valid v-show directives.
vue/valid-v-slot Enforce valid v-slot directives.
vue/valid-v-text Enforce valid v-text directives.

Default (24)

Added by happy-path, the default preset.

Rule What it checks Auto-fix
vue/attribute-hyphenation Enforce attribute naming style on custom components. ✓
vue/attribute-order Enforce a consistent order of attributes.
vue/component-definition-name-casing Enforce PascalCase or kebab-case for component definition names.
vue/html-end-tags Require end tags on HTML elements that may omit them. ✓
vue/html-quotes Enforce quotes style of HTML attributes. ✓
vue/mustache-interpolation-spacing Enforce consistent spacing inside mustache interpolations. ✓
vue/no-invalid-html-attribute Disallow invalid static values for HTML attributes.
vue/no-lone-template Disallow unnecessary <template> elements.
vue/no-multi-spaces Disallow multiple consecutive spaces. ✓
vue/no-template-shadow Disallow variable names that shadow variables in outer scope.
vue/no-template-target-blank Disallow target="_blank" without rel="noopener noreferrer".
vue/no-unsandboxed-iframe Require a sandbox attribute on iframe elements.
vue/no-unused-properties Disallow unused properties defined in defineProps.
vue/no-use-v-else-with-v-for Disallow using v-else-if or v-else on the same element as v-for.
vue/permitted-contents Enforce HTML content model rules.
vue/prop-name-casing Enforce a casing for declared prop names.
vue/require-scoped-style Require scoped attribute on style tags.
vue/sfc-element-order Enforce consistent order of SFC top-level elements.
vue/single-style-block Recommend having a single style block.
vue/this-in-template Disallow this. in template expressions.
vue/v-bind-style Enforce v-bind directive style. ✓
vue/v-on-event-hyphenation Enforce hyphenation of custom event names in v-on on components. ✓
vue/v-on-style Enforce v-on directive style. ✓
vue/v-slot-style Enforce v-slot directive style. ✓

Stricter presets (27)

Only in opinionated, nuxt or ecosystem. The Presets column lists which.

Rule What it checks Presets Auto-fix
vue/component-name-in-template-casing Enforce specific casing for component names in templates. nuxt, opinionated ✓
vue/html-button-has-type Require an explicit valid type on button elements. nuxt, opinionated
vue/html-self-closing Enforce self-closing style. nuxt, opinionated ✓
vue/no-array-index-key Disallow using the v-for index variable directly as the :key. nuxt, opinionated
vue/no-boolean-attr-value Disallow explicit values for boolean HTML attributes. nuxt, opinionated ✓
vue/no-empty-component-block Disallow empty SFC blocks. nuxt, opinionated
vue/no-inline-style Discourage use of inline style attributes. nuxt, opinionated
vue/no-multiple-objects-in-class Disallow multiple object literals inside a :class array binding. nuxt, opinionated
vue/no-negated-v-if-condition Disallow a negated v-if condition when the chain has a v-else. nuxt, opinionated
vue/no-preprocessor-lang Discourage CSS preprocessor usage in favor of modern CSS. nuxt, opinionated
vue/no-root-v-if Disallow v-if on the single root element of a template. nuxt, opinionated
vue/no-script-non-standard-lang Discourage non-standard script lang values. nuxt, opinionated
vue/no-src-attribute Discourage src attribute on SFC blocks. nuxt, opinionated
vue/no-template-lang Discourage lang attribute on template block. nuxt, opinionated
vue/no-unused-refs Report template refs (ref="x") never referenced in <script>. nuxt, opinionated
vue/no-useless-mustaches Disallow a mustache interpolation whose expression is a constant string literal. nuxt, opinionated
vue/no-useless-v-bind Disallow a v-bind whose value is a plain string literal. nuxt, opinionated
vue/no-v-text Disallow the v-text directive; prefer mustache interpolation. nuxt, opinionated
vue/prefer-props-shorthand Recommend shorthand syntax for props (Vue 3.4+). nuxt, opinionated ✓
vue/prefer-true-attribute-shorthand Prefer the shorthand for a boolean attribute bound to true. nuxt, opinionated
vue/require-component-registration Require explicit import or registration for components. opinionated
vue/scoped-event-names Recommend scoped event names using context:event format. nuxt, opinionated
vue/slot-name-casing Enforce kebab-case for named slots used via v-slot. nuxt, opinionated
vue/use-unique-element-ids Enforce unique element IDs using useId() instead of static literals. nuxt, opinionated
vue/v-on-handler-style Enforce writing v-on handlers as a method reference or an inline function. nuxt, opinionated
vue/warn-custom-block Warn about custom blocks in SFC files. nuxt, opinionated
vue/warn-custom-directive Warn about custom directives that need registration. nuxt, opinionated

Opt-in (16)

Not in any preset. Turn them on by name in the linter.rules passed to withVue.

Rule What it checks Auto-fix
vue/a11y-img-alt Require alt attribute on images for accessibility.
vue/match-component-file-name Require a component name to match its file name.
vue/max-template-complexity Limit a component's own template complexity (cyclomatic and cognitive).
vue/no-bare-strings-in-template Disallow raw human-readable text in the template that should be internationalized.
vue/no-custom-modifiers-on-v-model Disallow custom modifiers on v-model used on a component.
vue/no-multiple-template-root Disallow multiple root nodes in a template.
vue/no-ref-object-reactivity-loss Disallow copying a ref value in the same scope.
vue/no-setup-props-reactivity-loss Disallow setup prop reads that lose reactivity.
vue/no-static-inline-styles Disallow static inline style attributes.
vue/no-this-in-before-route-enter Disallow this in beforeRouteEnter.
vue/no-undefined-refs Disallow undefined variable references in templates.
vue/no-unused-setup-bindings Disallow unread script setup bindings.
vue/no-v-for-template-key Disallow key on <template v-for>.
vue/prefer-prop-type-boolean-first Enforce Boolean comes first in component prop types.
vue/require-expose Require declare public properties using expose.
vue/valid-model-definition Require valid keys in the model option.

Rules overview · Rule options · Migrating from ESLint