-
Notifications
You must be signed in to change notification settings - Fork 885
Improve rule curly with one-line if without braces #822
Comments
This would be nice to have. We've been using one-liners without curly braces for years across multiple projects. Now, after moving to TS and enabling TSLint, this aforementioned problem arose. |
I'm starting to implement this right now. I'd like to clear up the terminology a little bit and suggest these options: Note that the rule doesn't specify where it can reside or how many lines a statement is allowed use — that would be handled by another rule. Instead, it simply dictates whether or not it should have curly braces in some particular case. I got as granular as possible so that later we can add something like a In Scope:
Out of ScopeThe following seem like thing that should be allowed or denied by
|
This is implemented with #1565, and is waiting for review. |
I use single line 'if's everywhere and this fix is the ONLY thing keeping me from using tslint. |
I'm working on a slimmed-down PR as we speak, but there were some changes made around auto-fixes that are taking time to merge in. Something's coming, though. |
Having one-line if and else without braces is common:
ESLint allows this with
"curly": [2, "multi-line"]
. Would be nice for TSLint to support it.The text was updated successfully, but these errors were encountered: