TSLint : variable name must be in camelcase or uppercase

user762579 picture user762579 · Mar 29, 2017 · Viewed 30.7k times · Source

I have some variable names starting with leading underscore , I still get this warning after updating my tslint.json

tslint.json

{
  "extends": "tslint:recommended",
  "rules": {
    "variable-name": [
      true,
      "ban-keywords",
      "check-format",
      "allow-leading-underscore"
    ]
  },
  "exclude": [
    "build/**/*",
    "node_modules/**/*",
    "tmp/**/*"
  ]
}

where am I wrong ?

thanks for feedback

UPDATE

I am using version 4.5.1 of TSLint

Answer

Leonardo Venoso picture Leonardo Venoso · Jul 14, 2017

You can solve the problem by editing your tslint.json and adding "allow-leading-underscore" to the "variable-name" array of your "rules".

// tslint.json contents
{
  // ...
  "rules": {
    // ...
    "variable-name": [
      true,
      // ...
      "allow-leading-underscore"
    ]
  },
  // ...
}