[英]tslint: curly as-needed has no effect
https://palantir.github.io/tslint/rules/curly/ https://palantir.github.io/tslint/rules/curly/
I checked the document and added this in my tslint.json
file. 我检查了文档并将其添加到
tslint.json
文件中。
"curly": [
true, "as-needed"
],
However, when I ran tslint myapp.ts
, I still got error like below. 但是,当我运行
tslint myapp.ts
,仍然出现如下错误。
ERROR: express-app/app.ts[28, 5]: if statements must be braced
The statement it mentioned looks like this. 它提到的声明看起来像这样。
if (server)
server.close(() => console.log('closed'));
But I think with that curly configuration, tslint would allow me to write if statements like this. 但是我认为使用这种卷曲的配置, tslint可以让我编写类似if的语句。
{
"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": []
}
It looks like the "as-needed"
option was added in tslint@5.4.0
. 看起来
tslint@5.4.0
中添加了"as-needed"
选项。
To get it to work, update tslint
to that version (by running npm i -D tslint@^5.4.0
, or however else you like to update your dependencies). 要使其正常工作,
tslint
更新到该版本(通过运行npm i -D tslint@^5.4.0
,否则,您希望更新依赖项)。
Note this crosses a major version bump so there may be breaking changes. 请注意,这跨越了主要版本的障碍,因此可能会有重大更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.