-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
New: rest-spread-spacing rule (fixes #5391) #6278
Conversation
LGTM |
By analyzing the blame information on this pull request, we identified @nzakas, @scriptdaemon and @pedrottimark to be potential reviewers |
e321743
to
8bf1df9
Compare
return { | ||
SpreadElement: function(node) { | ||
var args = node.argument, | ||
operator = sourceCode.getTokenBefore(args); |
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.
I'd like to see a test for ...(foo)
.
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.
Great catch, will update with the fix
As this comment mentioned, I think we should support rest elements and experimentalObjectRestSpread in this rule. |
Missed that. Thanks - will update and report back. |
LGTM |
Thanks for pointing that stuff out, @mysticatea :) Updated |
operator = sourceCode.getTokenBefore(operator); | ||
} | ||
|
||
if (alwaysSpace && !sourceCode.isSpaceBetweenTokens(operator, args)) { |
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.
Maybe "never"
option of this rule is conflicting with the "always"
option of space-in-parens
rule: e.g. ...( foo )
.
I think this should check spacing between operator
and the next token of operator
, as same as fix functions.
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.
Makes sense - updated once more!
a2b7155
to
4b17cc3
Compare
Thank you for great works! (Though I cannot check documents!) |
}] | ||
}, | ||
{ | ||
code: "fn(... ( args ))", |
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.
Added tests to ensure compatibility with space-in-parens
4532fe3
to
8ffe15e
Compare
LGTM |
LGTM |
@mysticatea Refactored and simplified this logic after changing to account for parens. Thanks again for reviewing 👍 |
Lgtm. Nice job! |
No description provided.