vue/attribute-hyphenation
Enforce attribute naming style on custom components.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
Yes | Rule options |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The component attribute uses the camelCase spelling firstName.
<template>
<UserCard firstName="Ada" />
</template>
Good
The first-name spelling follows the configured hyphenated component-attribute convention.
<template>
<UserCard first-name="Ada" />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/attribute-hyphenation": "warn"
}
},
});
Then run vp run lint.