如何让tslint接受以“_”开头的变量名

How to make tslint accept variable name with "_" at the beginning

我有客户要求说需要 "_" 符号。我是这样添加的:

public _someVariable: string;

但是 tslint 说 variable name must be in lowerCamelCase, PascalCase or UPPER_CASE (variable-name)

我想在保留 tslint 配置的同时删除警报,这是我的 tslint 配置:

"variable-name": {
  "options": [
    "ban-keywords",
    "check-format",
    "allow-pascal-case"
  ]
},

设置allow-leading-underscore.

"variable-name": {
  "options": [
    "ban-keywords",
    "check-format",
    "allow-pascal-case",
    "allow-leading-underscore"
  ]
},

https://palantir.github.io/tslint/rules/variable-name/