vue/prefer-props-shorthand
Recommend shorthand syntax for props (Vue 3.4+).
| 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
Each binding repeats the corresponding variable name, including the camelCase equivalent of a hyphenated argument.
<template>
<MyComponent :foo="foo" />
<MyComponent :user-name="userName" />
<span :style="style" />
<div :aria-label="ariaLabel" />
</template>
Good
Vue 3.4+ same-name binding shorthand removes the repeated expressions; a different source variable such as bar remains explicit.
<template>
<MyComponent :foo />
<MyComponent :user-name />
<span :style />
<div :aria-label />
<MyComponent :foo="bar" />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/prefer-props-shorthand": "warn"
}
},
});
Then run vp run lint.