vue/prefer-props-shorthand
Recommend shorthand syntax for props (Vue 3.4+)
Default severity: warning
Presets: nuxt, opinionated
Automatic fix: Available for supported findings
Applies to: Vue SFC templates and blocks, with script context where the rule requires it
Options: No rule-specific options. Severity and preset selection are configurable.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/prefer-props-shorthand": "warn"
}
},
},
});
vp run lint
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>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.