vue/prop-name-casing Style
它的作用
强制 Vue 组件的 prop 名称使用特定的命名方式(camelCase 或 snake_case)。
这为什么不好?
不一致的 prop 命名会让模板更难阅读,也更难通过 grep 搜索。将整个代码库中的 props 固定为一种命名方式,可以让声明处和调用处保持一致。
示例
以下是此规则的错误代码示例(默认 camelCase):
vue
<script>
export default {
props: {
greeting_text: String,
},
};
</script>以下是此规则的正确代码示例(默认 camelCase):
vue
<script>
export default {
props: {
greetingText: String,
},
};
</script>配置
第 1 个选项
type: "camelCase" | "snake_case"
第 2 个选项
此选项是一个包含以下属性的对象:
ignoreProps
type: string[]
default: []
使用方法
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["vue"],
"rules": {
"vue/prop-name-casing": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["vue"],
rules: {
"vue/prop-name-casing": "error",
},
});bash
oxlint --deny vue/prop-name-casing --vue-plugin版本
此规则已在 v1.69.0 中添加。
