google / eslint-config-google

ESLint shareable config for the Google JavaScript style guide
Apache License 2.0
1.74k stars 140 forks source link

Fix: Update curly lint rule #42

Closed stramel closed 7 years ago

stramel commented 7 years ago

Went with multi-line based on lighthouse's eslintrc rules.

mutli-line: allow brace-less single-line if, else if, else, for, while, or do

The alternative one would be,

multi: http://eslint.org/docs/rules/curly#multi

philipwalton commented 7 years ago

I think this rule doesn't quite fit because technically the JS style guide only allows single line if statements (i.e. it doesn't allow if (foo) foo++; else doSomething();.

Though maybe it's better to have something turned on here than not since I think it's not very common to do the example above.

stramel commented 7 years ago

Hmmm you are correct it doesn't but I also don't see a rule to accomplish this with the current eslint configuration.

I think it would be better than not having any rule on it. Is that the only case missed by this rule?

philipwalton commented 7 years ago

Yeah, I think it's better to have an overly permissive rule than nothing (since nothing is also not correct). What I don't want is something that will incorrectly error on technically valid code.

Can you update your changes to keep the comment and then I'll merge?

stramel commented 7 years ago

@philipwalton I re-added but inline with the new rule and capped the line at 80 chars