script/component-options-name-casing
要求组件 name 选项使用 PascalCase。
| 默认严重程度 | 预设 | 自动修复 | 选项 |
|---|---|---|---|
error |
opinionated, nuxt |
不支持 | 无 |
适用范围:Vue SFC 中的 JS/TS 脚本;示例展示对应的 Options API 或 script setup 形式。
错误示例
组件选项 name: 'my-component' 使用 kebab-case,但此规则要求名称字面量采用 PascalCase。
<script lang="ts">
export default {
components: { myComponent }
}
</script>
正确示例
MyComponent 以大写字母开头,且仅包含字母和数字,满足名称检查。
<script lang="ts">
export default {
components: { MyComponent }
}
</script>
配置(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"script/component-options-name-casing": "error"
}
},
});
然后运行 vp run lint。