dwyl / goodparts

:see_no_evil: An ESLint Style that only allows JavaScript the Good Parts (and "Better Parts") in your code.
GNU General Public License v2.0
78 stars 26 forks source link

brace-style #217

Open eliasmalik opened 8 years ago

eliasmalik commented 8 years ago

http://eslint.org/docs/rules/brace-style

["error", "1tbs", { "allowSingleLine": true }]

Use 1tbs by default, allow single line statements, although should only use them in v. simple cases

nelsonic commented 8 years ago

At present the rule is requiring the else statement to start on the same line as the closing brace for the if:

if (condition) {
  // do things
} else {
  // do alternative things
}

I prefer the else on the next line for legibility ...

if (condition) {
  // do things
}
else {
  // do alternative things
}

Anyone have thoughts on this?

nelsonic commented 7 years ago

@eliascodes I very much prefer to use the Stroustrup brace style putting the else block start on the same level of indentation as the if as shown in the second example above makes the code more readable IMO... If nobody has any objections I would like to enforce "stroustrup" as our brace-style ...

eliasmalik commented 7 years ago

@nelsonic I have no particular objections, might want to ask someone who uses goodparts on a daily basis though.

Also be aware that JSLint takes the opposite view: screen shot 2016-11-23 at 11 11 22 screen shot 2016-11-23 at 11 11 07

nelsonic commented 7 years ago

@eliascodes great point! 🔍 Yeah, http://jslint.com/ expects "double-quotes" for String and four-spaces indentation ... 😕 Are we going to "conform" to all the JSLint "stylistic suggestions"...? 🤔

eliasmalik commented 7 years ago

@nelsonic not necessarily, I was just pointing it out. Like I said, I'm happy either way. You can make arguments for legibility/comprehension on both sides I think.