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

Last to first traversal option #11222

Open
rhumaric opened this issue Mar 6, 2020 · 1 comment
Open

Last to first traversal option #11222

rhumaric opened this issue Mar 6, 2020 · 1 comment

Comments

@rhumaric
Copy link

@rhumaric rhumaric commented Mar 6, 2020

Feature Request

  • I would like to work on this feature!

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I have an issue when

Hello,

I was implementing a transform to inject returns around the final statements of functions. For this, I had to traverse the list of statements last to first when in the bodys of BlockStatements, consequent and alternate of IfStatements...

Describe the solution you'd like
It would have been ideal if there was an option for traverse, maybe traverseNodeListLastToFirst, to go last to first when going through these list of node (but still go top bottom when when going down the tree, unlike what's originally proposed in #4956 if I understood correctly).

Describe alternatives you've considered
I tried to look into the code of traverse itself to understand a bit more how it worked. I got quite confused and I couldn't find when the looping of those lists happened so ended up implementing my own traversal.

Teachability, Documentation, Adoption, Migration Strategy

When traversing the AST with traverse the traverseNodeListLastToFirst will let you go through the list of nodes inside function, if, loops... bodies from the last to the first.

Just as when going first to last, skip will let you stop the processing of the siblings.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Mar 6, 2020

Hey @rhumaric! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.