vue/sort-keys
Require sorted object keys, compatible with component option order.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
None | No | Rule options |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The nested method keys are not in ascending order.
<script>
export default { methods: { zebra() {}, alpha() {} } }
</script>
<template />
Good
The nested method keys follow the configured order.
<script>
export default { methods: { alpha() {}, zebra() {} } }
</script>
<template />
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/sort-keys": "warn"
},
"ruleOptions": {
"vue/sort-keys": {
"order": "asc",
"caseSensitive": true,
"natural": false
}
}
},
});
Then run vp run lint.