Rule: variable-name

Checks variable names for various errors.


Six arguments may be optionally provided:

  • "check-format": allows only lowerCamelCased or UPPER_CASED variable names
    • "allow-leading-underscore" allows underscores at the beginning (only has an effect if “check-format” specified)
    • "allow-trailing-underscore" allows underscores at the end. (only has an effect if “check-format” specified)
    • "require-const-for-all-caps": enforces that all variables with UPPER_CASED names should be const.
    • "allow-pascal-case" allows PascalCase in addition to lowerCamelCase.
    • "allow-snake-case" allows snake_case in addition to lowerCamelCase.
  • "ban-keywords": disallows the use of certain TypeScript keywords as variable or parameter names.
    • These are: any, Number, number, String, string, Boolean, boolean, Undefined, undefined
Config examples
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"]
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
  "minLength": 0,
  "maxLength": 6