tslint:按需卷曲无效
tslint: curly as-needed has no effect
https://palantir.github.io/tslint/rules/curly/
我检查了文档并将其添加到我的 tslint.json
文件中。
"curly": [
true, "as-needed"
],
然而,当我运行 tslint myapp.ts
时,我仍然得到如下错误。
ERROR: express-app/app.ts[28, 5]: if statements must be braced
它提到的声明看起来像这样。
if (server)
server.close(() => console.log('closed'));
但我认为使用 curly 配置,tslint 将允许我编写 if像这样的陈述。
环境
- tslint: 4.5.1
- 打字稿:3.3.3333
完整 tslint.json
{
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"quotemark": [
true,
"single"
],
"curly": [
true, "as-needed"
],
"radix": [
false
],
"arrow-parens": [
true,
"ban-single-arg-parens"
],
"no-console": [
true,
"error"
]
},
"rulesDirectory": []
}
"as-needed"
选项似乎已添加到 tslint@5.4.0
。
要使其正常工作,请将 tslint
更新到该版本(通过 运行 npm i -D tslint@^5.4.0
,或者您喜欢更新依赖项的其他方式)。
请注意,这跨越了主要版本的颠簸,因此可能会有重大更改。
https://palantir.github.io/tslint/rules/curly/
我检查了文档并将其添加到我的 tslint.json
文件中。
"curly": [
true, "as-needed"
],
然而,当我运行 tslint myapp.ts
时,我仍然得到如下错误。
ERROR: express-app/app.ts[28, 5]: if statements must be braced
它提到的声明看起来像这样。
if (server)
server.close(() => console.log('closed'));
但我认为使用 curly 配置,tslint 将允许我编写 if像这样的陈述。
环境
- tslint: 4.5.1
- 打字稿:3.3.3333
完整 tslint.json
{
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"quotemark": [
true,
"single"
],
"curly": [
true, "as-needed"
],
"radix": [
false
],
"arrow-parens": [
true,
"ban-single-arg-parens"
],
"no-console": [
true,
"error"
]
},
"rulesDirectory": []
}
"as-needed"
选项似乎已添加到 tslint@5.4.0
。
要使其正常工作,请将 tslint
更新到该版本(通过 运行 npm i -D tslint@^5.4.0
,或者您喜欢更新依赖项的其他方式)。
请注意,这跨越了主要版本的颠簸,因此可能会有重大更改。