vue/no-boolean-attr-value
Disallow explicit values for boolean HTML attributes.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
nuxt, opinionated |
Yes | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The boolean disabled and checked attributes redundantly contain string values.
<template>
<input disabled="disabled" />
<input checked="checked" />
<button disabled="true">Save</button>
</template>
Good
The presence of each boolean attribute expresses the same enabled state without a value.
<template>
<input disabled />
<input checked />
<button disabled>Save</button>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-boolean-attr-value": "warn"
}
},
});
Then run vp run lint.