Vue 组件的 @typescript-eslint/naming-convention 解决方法
P粉785957729
P粉785957729 2024-03-26 16:14:32
0
1
329

我们启用了此规则: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/naming-convention.md#allowed-selectors-modifiers-and-types

默认情况下,这不允许在对象文字中使用 PascalCase,这对于 vue 组件来说是一个问题

export default defineComponent({
    name: 'MyComponent',
    components: {
      MyOtherComponent,
    },
  })

创建以下警告

对象文字属性名称 MyOtherComponent 必须匹配以下格式之一:camelCase

有没有人找到解决方法?我尝试了所有修改,但找不到一种可以解决问题且不允许在对象文字上使用 Pascal 的修改

P粉785957729
P粉785957729

全部回复(1)
P粉530519234

我可以重新创建它的唯一方法是使用规则:

"@typescript-eslint/naming-convention": [
                    "error",
                    {
                        "selector": "class",
                        "format": ["PascalCase"]
                    },

这不是默认的。所以我猜你的 eslintrc 文件中有这个或者正在使用这个集合的默认值。您应该能够覆盖它以使用:

{
    "selector": "class",
    "format": ["camelCase"]
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!