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

Fix path.remove() leading & trailing comments sharing #5504

Merged
merged 14 commits into from
Mar 23, 2017
Merged

Conversation

dmail
Copy link
Contributor

@dmail dmail commented Mar 19, 2017

Q A
Patch: Bug Fix? yes
Major: Breaking Change? no
Minor: New Feature? no
Deprecations? no
Spec Compliancy?
Tests Added/Pass? yes/yes
Fixed Tickets Fixes #5503
License MIT
Doc PR no
Dependency Changes no

It will be used to preserve comment ordering when a node is removed
@mention-bot
Copy link

@dmail, thanks for your PR! By analyzing the history of the files in this pull request, we identified @hzoo and @existentialism to be potential reviewers.

@babel-bot
Copy link
Collaborator

Hey @dmail! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time.

@babel-bot
Copy link
Collaborator

Hey @dmail! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time.

@babel-bot
Copy link
Collaborator

Hey @dmail! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time.

@codecov
Copy link

codecov bot commented Mar 19, 2017

Codecov Report

Merging #5504 into 7.0 will increase coverage by 0.12%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##              7.0    #5504      +/-   ##
==========================================
+ Coverage   85.31%   85.43%   +0.12%     
==========================================
  Files         200      200              
  Lines        9490     9512      +22     
  Branches     2696     2702       +6     
==========================================
+ Hits         8096     8127      +31     
+ Misses        894      886       -8     
+ Partials      500      499       -1
Impacted Files Coverage Δ
packages/babel-traverse/src/path/comments.js 93.1% <100%> (-2.73%) ⬇️
...ckages/babel-core/src/transformation/file/index.js 87.09% <0%> (-0.06%) ⬇️
...in-transform-es2015-template-literals/src/index.js 100% <0%> (ø) ⬆️
packages/babel-traverse/src/path/lib/hoister.js 90.9% <0%> (+0.18%) ⬆️
packages/babel-types/src/validators.js 84.95% <0%> (+0.27%) ⬆️
...bel-plugin-transform-es2015-classes/src/vanilla.js 90.17% <0%> (+0.42%) ⬆️
packages/babel-types/src/converters.js 91.03% <0%> (+0.75%) ⬆️
packages/babel-traverse/src/path/replacement.js 74.33% <0%> (+0.88%) ⬆️
packages/babel-traverse/src/path/modification.js 74.75% <0%> (+0.97%) ⬆️
... and 5 more

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 baafe48...cf2c912. Read the comment docs.

@babel-bot
Copy link
Collaborator

Hey @dmail! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time.

When the node has no siblings its comments must be shared with its parent. I'll add test in next commit.
@dmail
Copy link
Contributor Author

dmail commented Mar 20, 2017

Sorry for the commits noise. This pull request is still missing specific tests.

@babel-bot
Copy link
Collaborator

Hey @dmail! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time.

@babel-bot
Copy link
Collaborator

Hey @dmail! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time.

@dmail
Copy link
Contributor Author

dmail commented Mar 20, 2017

I won't commit more now all checks are passing.

At the moment, this pull request prevents comments order being messed up when using path.remove(). However, tests added by this PR demonstrates that path.remove() still have a negative impact on comment outputs.

I cannot go further because of how comments are stored in the tree. I mean leadingComments & trailingComments properties on nodes does not seems to be sufficient to preserve comment when a node is removed.

Let me know if this pull request helps you,
Cheers.

@hzoo hzoo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Mar 23, 2017
@hzoo
Copy link
Member

hzoo commented Mar 23, 2017

Yeah we may have to redo comments based on how eslint/prettier are handling them

Copy link
Member

@hzoo hzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good,

Made dmail-fork#1 for fixture tests instead of js

@dmail
Copy link
Contributor Author

dmail commented Mar 23, 2017

Warning : Travis says tests are passing but TEST_ONLY=babel-traverse make test is currently failing.

I'm noticing that your comments/attachment/expected.js are expecting correct comment outputs.

For instance you're expecting

hasPrev;
/* top */
/* left */willRemove;/* right */
/* bottom */

To become

hasPrev;
/* top */
/* left */ /* right */
/* bottom */

However the current output is

hasPrev; /* top */ /* left */ /* right */ /* bottom */

@hzoo
Copy link
Member

hzoo commented Mar 23, 2017

@dmail it works locally for me (both make test-only and TEST_ONLY)

oh I had the same problem originally: it's because if you just npm install it installs the old version rather than the version of babel-traverse that's linked. If you make bootstrap again it should work

@hzoo hzoo merged commit 299e512 into babel:7.0 Mar 23, 2017
@hzoo
Copy link
Member

hzoo commented Mar 23, 2017

Truly awesome work @dmail! thanks 👏

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants