-
Notifications
You must be signed in to change notification settings - Fork 513
New Rule: requireNewlineBeforeBlockStatements #536
Conversation
Hi @cipiripper , thanks for contributing! In order for us to land this pull request, please do the following:
Thanks again for your help! |
Oooh, didn't know about that... Sorry! I'll follow your guide now... :) |
No worries. Thanks again! |
@cowwoc can you please comment on the actual PR instead of the commit so they appear inline? |
@@ -2549,6 +2549,71 @@ Values: `true` | |||
// A comment | |||
``` | |||
|
|||
### disallowNewlineBeforeBlockStatements | |||
|
|||
Disallows newline before opening round bracket of block statements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
round bracket
-> curly brace
Okay, thanks, will fix those shortly. :) |
I think the documentation should indicate that rule is applied where possible and explicitly mention that |
@cowwoc Hm true. |
The latest commit looks good to me. |
var openingBrace = tokens[openingBracePos]; | ||
var prevToken = tokens[openingBracePos - 1]; | ||
|
||
if (openingBrace.loc.start.line !== prevToken.loc.start.line && prevToken.value !== 'return') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for return here is not needed. Please remove.
@cipiripper one last change to make and then I think this is good to land! |
@mikesherov You're going to hate me but I think we need to address the following issues as well:
We can add two additional rules to cover the closing brace, or rename this rule to |
before implementing the parameter. |
Sorry for any confusion I have caused. I'm going to provide a concrete example of what I'm expecting and we can then break it down into one or more rules:
Open questions for @mikesherov:
I'm trying to make sure the terminology is consistent across all rules. One option is to break this down to 8 separate rules:
and the |
@cowwoc can we move these discussions to new issues. I'd really only like to focus on the opening curly brace of a block statement (not objects) for this rule as they are fundamentally different. As far as what these rules should do:
|
@mikesherov Okay, I'll open separate issues. Thanks. |
👍 |
Thanks! Landed in 6dc228a |
Solves this issue: #65
This rule gets the oppening brace of a BlockStatement, and comapres is vertical location to the previous token vertical location. If those two are equal, that is an error.