# san/component-tags-order
要求组件顶级元素的顺序
- ⚙️ 此规则包含于
"plugin:san/recommended"
.
# 📖 规则细节
此规则会要求<script>
、<template>
和<style>
标签的顺序。
# 🔧 配置
{
"san/component-tags-order": ["error", {
"order": [ [ "script", "template" ], "style" ]
}]
}
order
((string|string[])[]
) ... 组件顶级元素的顺序。默认[ [ "script", "template" ], "style" ]
.
# { "order": [ [ "script", "template" ], "style" ] }
(默认)
<!-- ✓ GOOD -->
<script>/* ... */</script>
<template>...</template>
<style>/* ... */</style>
<!-- ✓ GOOD -->
<template>...</template>
<script>/* ... */</script>
<style>/* ... */</style>
<!-- ✗ BAD -->
<style>/* ... */</style>
<script>/* ... */</script>
<template>...</template>
# { "order": ["template", "script", "style"] }
<!-- ✓ GOOD -->
<template>...</template>
<script>/* ... */</script>
<style>/* ... */</style>
<!-- ✗ BAD -->
<script>/* ... */</script>
<template>...</template>
<style>/* ... */</style>
# { "order": ["docs", "template", "script", "style"] }
<!-- ✓ GOOD -->
<docs> documents </docs>
<template>...</template>
<script>/* ... */</script>
<style>/* ... */</style>
<!-- ✗ BAD -->
<template>...</template>
<script>/* ... */</script>
<docs> documents </docs>
<style>/* ... */</style>