Vize

a11y/no-autofocus

Disallow the use of the autofocus attribute.

Default severity Presets Automatic fix Options
warning happy-path, nuxt, ecosystem, opinionated No None

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

Bad

The input requests automatic focus when it appears.

<template>
  <input autofocus name="query" />
</template>

Good

Removing autofocus avoids this automatic focus request while retaining the query input.

<template>
  <input name="query" />
</template>

Configuration (Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "a11y/no-autofocus": "warn"
    }
  },
});

Then run vp run lint.