vue/attribute-order
Enforce a consistent order of attributes
Default severity: warning
Presets: happy-path, nuxt, ecosystem, opinionated
Automatic fix: None; review the suggested change
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/attribute-order": "warn"
}
},
},
});
vp run lint
Bad
The event handler appears before the structural v-if directive and ordinary id attribute.
<template>
<div @click="onClick" v-if="show" id="main"></div>
</template>
Good
v-if comes first, followed by id and then the event handler, following the rule ordering.
<template>
<div v-if="show" id="main" @click="onClick"></div>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.