https://palantir.github.io/tslint/rules/curly/
I checked the document and added this in my tslint.json
file.
"curly": [
true, "as-needed"
],
However, when I ran tslint myapp.ts
, I still got error like below.
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.
{
"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
.
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).
Note this crosses a major version bump so there may be breaking changes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.