Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

RFE: Braces should be opened on newline whenever possible #65

Closed
cowwoc opened this issue Nov 4, 2013 · 7 comments
Closed

RFE: Braces should be opened on newline whenever possible #65

cowwoc opened this issue Nov 4, 2013 · 7 comments
Labels

Comments

@cowwoc
Copy link

cowwoc commented Nov 4, 2013

Please add a rule that requires opening braces on new line, whenever possible. For example:

function good()
{
  // body goes here
}

instead of:

function bad() {
  // body goes here
}

The only case I'm aware of where this is disallowed is for returning anonymous objects:

return {
  "key": value
}
@mdevils
Copy link
Member

mdevils commented Dec 20, 2013

I would accept a proper pull-request on this.

@timmywil
Copy link

timmywil commented Jun 4, 2014

I would like the opposite to be enforced by an option.

@timmywil
Copy link

timmywil commented Jun 4, 2014

But only for statements. For instance, I'd like to differentiate between

var o = {
  key: [{
    a: 0
  },
  // okay
  {
    a: 1
  }]
};

and

// good
if (true) {
}
// bad
if (true)
{
}

By statements, I mean, if, else, for, while, switch, do, return, try, catch, and function. Elsewhere is fine.

Perhaps the exception could be narrowed down to whenever the curly is preceded by comma and optional whitespace.

@mikesherov
Copy link
Contributor

@timmywil you mean all blockStatements and not objectExpressions, right?

This would be similar to *SpaceBeforeBlockStatements and be called *NewlineBeforeBlockStatements. Sound good?

@timmywil
Copy link

timmywil commented Jun 4, 2014

@mikesherov Yes, thank you for putting it concisely. Sounds great.

@bhardin
Copy link

bhardin commented Jul 28, 2014

I agree with @timmywil, I'd like to have a rule to enforce the opposite also. Was NewlineBeforeBlockStatements ever implemented?

@cowwoc
Copy link
Author

cowwoc commented Jul 29, 2014

@bhardin yes, but it has yet to be merged. See #536

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

No branches or pull requests

5 participants