attributes-order
What it does
Section titled “What it does”Reports an attribute that is out of the recommended order: is, v-for, conditions (v-if, v-else-if, v-else, v-show), v-pre and v-once, id, ref, key and slots, v-model, other directives, plain and bound attributes, events, and v-html and v-text last. A bare v-bind="object" takes the place of the attribute it precedes. The order is not alphabetical. Only in .vue files.
Why it matters
Section titled “Why it matters”A fixed order puts the directives that decide whether and how often an element exists first, so a reader sees at once what the element is before they read how it looks.
To fix, move the attribute to its place in the order.
Example
Section titled “Example”... <div>text</div>... <a @click="go" :href="u" v-if="ok">x</a> <a v-if="ok" :href="u" @click="go">x</a> <input v-bind="props" :id="i" v-model="m">...Configuration
Section titled “Configuration”angular: lint: rules: attributes-order: warn # off (default), warn, errorhtml: lint: rules: attributes-order: warn # off (default), warn, errorsvelte: lint: rules: attributes-order: warn # off (default), warn, errorvue: lint: rules: attributes-order: warn # off (default), warn, errorEnabled by the presets: html/eslint-plugin-vue-recommended.
Suppress one line with sudsy-disable-next-line attributes-order in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| eslint-plugin-vue | attributes-order |
partial | the default order, no alphabetical, order or sortLineLength option, no fix |