18 typescript tslint
我有一些以前导下划线开头的变量名称,在更新我的tslint.json后仍然会收到此警告
tslint.json
{
"extends": "tslint:recommended",
"rules": {
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-leading-underscore"
]
},
"exclude": [
"build/**/*",
"node_modules/**/*",
"tmp/**/*"
]
}
Run Code Online (Sandbox Code Playgroud)
我哪里错了?
谢谢你的反馈
UPDATE
我使用的是TSLint的4.5.1版本
Leo*_*oso 26
你可以这样解决问题:
{
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-leading-underscore"
]
},
"rulesDirectory": []
}
Run Code Online (Sandbox Code Playgroud)
Sha*_*ank 19
我已经更新tslint.json、配置了文件并向变量名数组添加了可选参数。
"allow-leading-underscore"允许在开头使用下划线(仅在指定“check-format”时有效)
"allow-pascal-case"除了lowerCamelCase之外,还允许PascalCase。
"allow-snake-case"除了lowerCamelCase之外,还允许snake_case。
"allow-trailing-underscore"最后允许下划线。(仅在指定“check-format”时有效)
{
// ...
"rules": {
"variable-name": [
true,
"allow-leading-underscore"
],
},
// ...
}
Run Code Online (Sandbox Code Playgroud)
您可以tslint.json根据您的要求进行配置。
此链接可能会有所帮助。https://palantir.github.io/tslint/rules/variable-name/
| 归档时间: |
|
| 查看次数: |
14424 次 |
| 最近记录: |