Home  >  Q&A  >  body text

@typescript-eslint/naming-convention workaround for Vue components

We have enabled this rule: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/naming-convention.md#allowed-selectors-modifiers-and-types

By default this does not allow the use of PascalCase in object literals, which is a problem for vue components

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

Create the following warning

Object literal property name MyOtherComponent must match one of the following formats: camelCase

Is there �%

P粉785957729P粉785957729206 days ago334

reply all(1)I'll reply

  • P粉530519234

    P粉5305192342024-03-27 15:53:40

    The only way I can recreate it is using the rules:

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

    This is not the default. So I'm guessing you have this in your eslintrc file or are using the default values ​​for this collection. You should be able to override this to use:

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

    reply
    0
  • Cancelreply