#lazytwitter Can someone write an eslint rule that disallows` braceless if` when:
- newline before the expr
- >1 stmt on the same line
1/
-
-
Replying to @wycats
allowed: if (!isAdmin) return; if (failedAssertion) throw new Error(reason); if (!x) x = 1; 2/
1 reply 0 retweets 2 likes -
Replying to @wycats
disallowed: if (!isAdmin) return; if (failedAssertion) reset(); throw new Error(reason); if (!x) x = 1; y = 2; 3/3
1 reply 0 retweets 1 like -
Replying to @wycats
I think it makes sense to require a newline after single-expression braceless if too. disallowed: if (x) x = 1; y = 2;
3 replies 0 retweets 2 likes -
Replying to @wycats
you mean with indentation level increasing on second line?
2 replies 0 retweets 0 likes -
Replying to @BrendanEich
I'm just frustrated that simple guards are disallowed to avoid mistakes that are easily disambiguated and linter.
1 reply 1 retweet 1 like -
Replying to @wycats
I think if-then on one line can be part of a consistent style, but it adds a small risk delta. I've avoided it since my Pascal days.
1 reply 0 retweets 4 likes -
Replying to @BrendanEich
with a good linter, the risk Delta should be 0
2 replies 0 retweets 3 likes -
Replying to @wycats
I was thinking of my own move away from that element of Pascal style. Wirth's books, still <3 'em, use multiple statements per line.
3 replies 0 retweets 0 likes
people cargo culted a mental rule into a tool that doesn't have memorization constraints. Mistake.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.