# san/order-in-components
enforce order of properties in components
- ⚙️ This rule is included in
"plugin:san/recommended"
. - 🔧 The
--fix
option on the command line (opens new window) can automatically fix some of the problems reported by this rule.
# 📖 Rule Details
This rule makes sure you keep declared order of properties in components.
<script>
/* ✓ GOOD */
export default {
dataTypes: {
name: DataTypes.string
},
initData () {
return {
msg: 'Welcome to Your San App'
}
}
}
</script>
<script>
/* ✗ BAD */
export default {
initData () {
return {
msg: 'Welcome to Your San App'
}
},
dataTypes: {
name: DataTypes.string
}
}
</script>
# 🔧 Options
{
"san/order-in-components": ["error", {
"order": [
// 视图
"template",
"components",
"trimWhitespace",
// 事件
"messages",
// 数据
"dataTypes",
"computed",
"filters",
"initData",
// 生命周期
"LIFECYCLE_HOOKS"
]
}]
}
order
((string | string[])[]
) ... The order of properties. Elements are the property names or one of the following groups:LIFECYCLE_HOOKS
: San Lifecycle Events (opens new window), in the order they are called
If an element is an array of strings, it means any of those can be placed there unordered. Default is above.