Appearance
vue/match-component-file-name
要求组件 name 属性与其文件名匹配
- 💡 此规则报告的某些问题可由编辑器 suggestions 手动修复。
此规则报告组件 name
属性是否与其文件名不匹配。
¥This rule reports if a component name
property does not match its file name.
你可以定义此规则应为组件名称验证的文件扩展名数组。
¥You can define an array of file extensions this rule should verify for the component's name.
📖 规则详情
此规则有一些选项。
¥This rule has some options.
json
{
"vue/match-component-file-name": ["error", {
"extensions": ["jsx"],
"shouldMatchCase": false
}]
}
默认情况下,此规则将仅验证具有 .jsx
扩展名的文件中的组件。
¥By default this rule will only verify components in a file with a .jsx
extension.
你可以使用 ".js"
、".jsx"
、".ts"
、".tsx"
和 ".vue"
扩展的任意组合。
¥You can use any combination of ".js"
, ".jsx"
, ".ts"
, ".tsx"
, and ".vue"
extensions.
你还可以强制组件名称和文件名之间的大小写相同。
¥You can also enforce same case between the component's name and its file name.
如果你在同一个文件中定义多个组件,则此规则将被忽略。
¥If you are defining multiple components within the same file, this rule will be ignored.
🔧选项
¥🔧 Options
json
{
"vue/match-component-file-name": ["error", {
"extensions": ["jsx"],
"shouldMatchCase": false
}]
}
"extensions": []
...要验证的文件扩展名数组。默认值设置为["jsx"]
。¥
"extensions": []
... array of file extensions to be verified. Default is set to["jsx"]
."shouldMatchCase": false
...布尔值,表示组件的名称是否也应与其文件名大小写相匹配。默认值设置为false
。¥
"shouldMatchCase": false
... boolean indicating if component's name should also match its file name case. Default is set tofalse
.
{extensions: ["vue"]}
{extensions: ["js"]}
{shouldMatchCase: true}
📚扩展阅读
¥📚 Further Reading
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v5.2.0 中引入
¥This rule was introduced in eslint-plugin-vue v5.2.0
🔍代码实现
¥🔍 Implementation