# 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>
Now loading...
<!-- ✓ GOOD --> <template>...</template> <script>/* ... */</script> <style>/* ... */</style>
Now loading...
<!-- ✗ BAD --> <style>/* ... */</style> <script>/* ... */</script> <template>...</template>
Now loading...

# { "order": ["template", "script", "style"] }

<!-- ✓ GOOD --> <template>...</template> <script>/* ... */</script> <style>/* ... */</style>
Now loading...
<!-- ✗ BAD --> <script>/* ... */</script> <template>...</template> <style>/* ... */</style>
Now loading...

# { "order": ["docs", "template", "script", "style"] }

<!-- ✓ GOOD --> <docs> documents </docs> <template>...</template> <script>/* ... */</script> <style>/* ... */</style>
Now loading...
<!-- ✗ BAD --> <template>...</template> <script>/* ... */</script> <docs> documents </docs> <style>/* ... */</style>
Now loading...

# 🔍 实现