[英]TSLint : variable name must be in camelcase or uppercase
I have some variable names starting with leading underscore , I still get this warning after updating my tslint.json我有一些以下划线开头的变量名,更新我的 tslint.json 后我仍然收到这个警告
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我使用的是 4.5.1 版的 TSLint
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
并将"allow-leading-underscore"
到"rules"
的"variable-name"
数组来解决问题。
// tslint.json contents
{
// ...
"rules": {
// ...
"variable-name": [
true,
// ...
"allow-leading-underscore"
]
},
// ...
}
I have updated tslint.json
, configured the file and added optional arguments to the array of variable-name.我更新了
tslint.json
,配置了文件并向变量名数组添加了可选参数。
"allow-leading-underscore"
allows underscores at the beginning (only has an effect if “check-format” specified)"allow-leading-underscore"
允许在开头使用下划线(仅在“check-format”指定时才有效)
"allow-pascal-case"
allows PascalCase in addition to lowerCamelCase."allow-pascal-case"
允许除了lowerCamelCase 之外的PascalCase。
"allow-snake-case"
allows snake_case in addition to lowerCamelCase."allow-snake-case"
允许snake_case 和lowerCamelCase。
"allow-trailing-underscore"
allows underscores at the end."allow-trailing-underscore"
允许在末尾使用下划线。 (only has an effect if “check-format” specified)(仅在指定“check-format”时有效)
{
// ...
"rules": {
"variable-name": [
true,
"allow-leading-underscore"
],
},
// ...
}
You can configure tslint.json
according to your requirements.您可以根据需要配置
tslint.json
。
This link might be helpful.此链接可能会有所帮助。 https://palantir.github.io/tslint/rules/variable-name/
https://palantir.github.io/tslint/rules/variable-name/
You can solve the problem by editing your tslint.json and adding all this properties to the "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.