【问题标题】:@typescript-eslint/naming-convention workaround for Vue componentsVue 组件的 @typescript-eslint/naming-convention 解决方法
【发布时间】:2022-05-06 17:53:51
【问题描述】:

我们已启用此规则: 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,
    },
  })

创建以下警告

Object Literal Property name MyOtherComponent 必须匹配以下格式之一:camelCase

有人找到解决方法了吗?我尝试了所有修改,但找不到解决问题的修改,而不允许对象文字上的 Pascal

【问题讨论】:

    标签: vue.js eslint typescript-eslint


    【解决方案1】:

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

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

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

    {
        "selector": "class",
        "format": ["camelCase"]
    }
    

    【讨论】:

      猜你喜欢
      • 2022-12-16
      • 2021-12-26
      • 1970-01-01
      • 2022-11-10
      • 2021-06-02
      • 2020-08-13
      • 2019-11-11
      • 2021-07-17
      • 2020-11-10
      相关资源
      最近更新 更多