Eslint naming convention rule for specific variable name

Discussão em 'Angular' iniciado por TCH, Abril 14, 2025.

  1. TCH

    TCH Guest

    I develop an Angular project and I use an eslint with a rule for modifiers protected readonly to be in strictCamelCase as follow :

    {
    "selector": ["classProperty"],
    "format": ["strictCamelCase"],
    "leadingUnderscore": "forbid",
    "trailingUnderscore": "forbid",
    "modifiers": ["protected", "readonly"]
    }


    I use some enums in my project such as EnumButtonSize and I use to declare it like:

    protected readonly EnumButtonSize = EnumButtonSize;

    • The modifier readonly should be enough, but I use Storybook in my project and I then have to add the protected modifier to make this variable not present in Storybook documentation (alternative is to add a comment /** */ with @internal decorator above the variable)
    • This variable is meant to be used in the template like <my-button [buttonSize]="EnumButtonSize.LARGE">

    I'd like to add a specific eslint rule to support theses enums in PascalCase. I tryed something like that without success:

    {
    "selector": ["classProperty"],
    "format": ["StrictPascalCase"],
    "leadingUnderscore": "forbid",
    "trailingUnderscore": "forbid",
    "modifiers": ["protected", "readonly"],
    "custom": {
    "regex": "^Enum.*",
    "match": true
    }
    },


    Can someone help me or have a different idea ?

    Continue reading...

Compartilhe esta Página