Skip to content

variable-name removed in gts@2.0.0 #486

@zamnuts

Description

@zamnuts

TSLint's variable-name rule existed in gts@1:

gts/tslint-rules.json

Lines 70 to 76 in 4f21151

"variable-name": [
true,
"check-format",
"ban-keywords",
"allow-leading-underscore",
"allow-trailing-underscore"
]

Per typescript-eslint's ROADMAP style section (migration guide?), the TSLint variable-name equivalent is now @typescript/naming-convention. See rules/naming-convention.

Since variable-name was removed and naming-convention was not included, variable name linting is now more relaxed, i.e. a possible regression.

While the new naming-convention allows for significantly more control, a 1:1 replacement would be:

---
rules:
  '@typescript-eslint/naming-convention':
    - error
    - selector: variable
      format: ['camelCase', 'UPPER_CASE']
      leadingUnderscore: allow
      trailingUnderscore: allow
      custom:
        regex: 'any|[Nn]umber|[Ss]tring|[Bb]oolean|[Uu]ndefined'
        match: false

naming-convention does not explicitly include support for the ban-keywords option, so custom with a regex was included above to provide equivalency. See https://github.com/palantir/tslint/blob/8efa78e35a88b62775ce3c9bf0fa00586b0d34e1/src/rules/variableNameRule.ts#L26-L36

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions