-
Notifications
You must be signed in to change notification settings - Fork 73
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
Omit semicolon in for statements init and loop expressions #69
Conversation
Codecov Report
@@ Coverage Diff @@
## master #69 +/- ##
==========================================
+ Coverage 85.14% 85.36% +0.21%
==========================================
Files 5 5
Lines 202 205 +3
Branches 43 45 +2
==========================================
+ Hits 172 175 +3
Misses 28 28
Partials 2 2
Continue to review full report at Codecov.
|
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 like very much this solution @fvictorio awesome work; also I was thinking about using the same technique for the VariableDeclarationStatement
type? can we do that?
I think so. I'll take a look. |
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've added a small change; let me know what you think and happy to merge if you like @fvictorio
@@ -245,8 +244,7 @@ function genericPrint(path, options, print) { | |||
if (node.initialValue) { | |||
doc = concat([doc, ' = ', path.call(print, 'initialValue')]); | |||
} | |||
const addSemicolon = path.getParentNode().type !== 'ForStatement'; | |||
return concat([doc, addSemicolon ? ';' : '']); | |||
return concat([doc, node.omitSemicolon ? '' : ';']); |
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.
and it works also here! this is fantastic 👍
Closes #64.
I ended up mutating the nodes anyway, but I did it in the parser, which make it a little less ugly (or so I tell myself). The problem is that we don't have a better
type
to assign to this nodes; at least I didn't see one that could work.Maybe later we can do it in a cleaner way. For now, tests pass and I don't think it's a huge technical debt.