Vue · Template

VUE0022Require explicit button type

Require native buttons to declare type so form behavior is explicit.

Why it happens

A native button defaults to submit inside forms, which can trigger accidental form submissions.

Fix

Add type="button", type="submit", or type="reset" to native buttons.

Example

Use explicit button type

Before

<template>
  <button @click="save">Save</button>
</template>

After

<template>
  <button type="button" @click="save">Save</button>
</template>

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vue --rules vue/template/html-button-has-type
Copyright © 2026