Vize

vue/no-empty-component-block

禁止空的 SFC 块。

默认严重程度 预设 自动修复 选项
warning nuxt, opinionated 不支持 无

适用范围:Vue SFC 模板和代码块,包括规则所需的脚本上下文。

错误示例

template、script 和 style 块都没有实质内容。

<template></template>

<script></script>

<style>
</style>

正确示例

每个保留的块都包含实际的标记、脚本声明或样式声明。

<template>
  <div>Hello</div>
</template>

<script setup>
const message = "Hello";
</script>

<style scoped>
.button { color: red; }
</style>

配置(Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/no-empty-component-block": "warn"
    }
  },
});

然后运行 vp run lint。

相关页面