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

Omit semicolon in for statements init and loop expressions #69

Merged
merged 5 commits into from
Oct 31, 2018

Conversation

fvictorio
Copy link
Member

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.

@codecov
Copy link

codecov bot commented Oct 22, 2018

Codecov Report

Merging #69 into master will increase coverage by 0.21%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/parser.js 100% <100%> (ø) ⬆️
src/printer.js 83.03% <100%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7b81dd...8326054. Read the comment docs.

Copy link
Member

@mattiaerre mattiaerre left a 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?

@mattiaerre mattiaerre added this to the alpha launch milestone Oct 23, 2018
@fvictorio
Copy link
Member Author

I think so. I'll take a look.

Copy link
Member

@mattiaerre mattiaerre left a 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 ? '' : ';']);
Copy link
Member

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 👍

@mattiaerre mattiaerre merged commit 11363ca into master Oct 31, 2018
@mattiaerre mattiaerre deleted the issue-for-statement branch October 31, 2018 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants