Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brace-style #217

Open
eliasmalik opened this issue Sep 21, 2016 · 5 comments
Open

brace-style #217

eliasmalik opened this issue Sep 21, 2016 · 5 comments

Comments

@eliasmalik
Copy link
Contributor

eliasmalik commented Sep 21, 2016

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
Copy link
Member

nelsonic commented Oct 3, 2016

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 nelsonic reopened this Oct 3, 2016
@nelsonic
Copy link
Member

nelsonic commented Nov 23, 2016

@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
Copy link
Contributor Author

@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
Copy link
Member

nelsonic commented Nov 23, 2016

@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
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants