vue/block-order
强制组件顶层元素的顺序
- 🔧 命令行 上的
--fix
选项可以自动修复此规则报告的一些问题。
📖 规则详情
此规则会警告顶层标签的顺序,例如 <script>
、<template>
和 <style>
。
🔧 选项
json
{
"vue/block-order": ["error", {
"order": [ [ "script", "template" ], "style" ]
}]
}
order
((string|string[])[]
) ... 顶层元素名称的顺序。默认[ [ "script", "template" ], "style" ]
。也可以是 CSS 选择器,例如script[setup]
和i18n:not([locale=en])
。
{ "order": [ [ "script", "template" ], "style" ] }
(默认)
{ "order": ["template", "script", "style"] }
{ "order": ["docs", "template", "script", "style"] }
{ 'order': ['template', 'script:not([setup])', 'script[setup]'] }
{ 'order': ['template', 'style:not([scoped])', 'style[scoped]'] }
{ 'order': ['template', 'i18n:not([locale=en])', 'i18n[locale=en]'] }
📚 进一步阅读
🚀 版本
此规则在 eslint-plugin-vue v9.16.0 中引入