[英]TSLint : variable name must be in camelcase or uppercase
我有一些以下划线开头的变量名,更新我的 tslint.json 后我仍然收到这个警告
tslint.json
{
"extends": "tslint:recommended",
"rules": {
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-leading-underscore"
]
},
"exclude": [
"build/**/*",
"node_modules/**/*",
"tmp/**/*"
]
}
我哪里错了?
感谢反馈
更新
我使用的是 4.5.1 版的 TSLint
您可以通过编辑tslint.json
并将"allow-leading-underscore"
到"rules"
的"variable-name"
数组来解决问题。
// tslint.json contents
{
// ...
"rules": {
// ...
"variable-name": [
true,
// ...
"allow-leading-underscore"
]
},
// ...
}
我更新了tslint.json
,配置了文件并向变量名数组添加了可选参数。
"allow-leading-underscore"
允许在开头使用下划线(仅在“check-format”指定时才有效)
"allow-pascal-case"
允许除了lowerCamelCase 之外的PascalCase。
"allow-snake-case"
允许snake_case 和lowerCamelCase。
"allow-trailing-underscore"
允许在末尾使用下划线。 (仅在指定“check-format”时有效)
{
// ...
"rules": {
"variable-name": [
true,
"allow-leading-underscore"
],
},
// ...
}
您可以根据需要配置tslint.json
。
此链接可能会有所帮助。 https://palantir.github.io/tslint/rules/variable-name/
您可以通过编辑 tslint.json 并将所有这些属性添加到 "variable-name" 来解决问题:
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"allow-pascal-case",
"allow-leading-underscore",
"allow-snake-case",
"allow-trailing-underscore",
"require-const-for-all-caps"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.