vue/component-definition-name-casing Style
作用
强制组件定义名称使用特定的大小写格式。
为什么这很糟糕?
如果组件名称没有统一的大小写格式,模板会更难阅读, 也更难通过 grep 搜索。选择 PascalCase 或 kebab-case 其中一种并在整个代码库中保持一致,可以消除一类 无谓争论和搜索遗漏。
示例
以下是此规则的错误代码示例(默认 PascalCase):
vue
<script>
export default {
name: "foo-bar",
};
</script>以下是此规则的正确代码示例(默认 PascalCase):
vue
<script>
export default {
name: "FooBar",
};
</script>配置
此规则接受以下字符串值之一:
type: "PascalCase" | "kebab-case"
使用方法
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["vue"],
"rules": {
"vue/component-definition-name-casing": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["vue"],
rules: {
"vue/component-definition-name-casing": "error",
},
});bash
oxlint --deny vue/component-definition-name-casing --vue-plugin版本
此规则在 v1.68.0 中加入。
