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

D A*_*T D 3 typescript tslint

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

public _someVariable: string;
Run Code Online (Sandbox Code Playgroud)

但 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"
  ]
},
Run Code Online (Sandbox Code Playgroud)

小智 10

allow-leading-underscore

"variable-name": {
  "options": [
    "ban-keywords",
    "check-format",
    "allow-pascal-case",
    "allow-leading-underscore"
  ]
},
Run Code Online (Sandbox Code Playgroud)

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