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

feat: support passing custom parser to recast #354

Closed
wants to merge 1 commit into from

Conversation

pionxzh
Copy link
Contributor

@pionxzh pionxzh commented Jan 11, 2024

closes #352

This PR adds a third argument options to the transform method. User can pass any parser that is compatible with recast (example), this parser should have a parse method that accepts code and returns AST.

Qustions:

  1. destructParam imports the internal parser to parse the code, which is not covered by this PR. I'm not sure if I should change the transformer interface from function(ast, logger) to function(ast, logger, parser) so that the parser config can cover all of the usage.

@nene
Copy link
Collaborator

nene commented Jan 11, 2024

Hi. Thanks for the pull request.

I have to say though, that I don't think it's the right way to fix this problem, because:

  • it doesn't actually fix the problem, it only makes it possible for people who run into the problem to work around it by passing in a different parser.

I think instead we should just completely replace the parser when espree is problematic. Perhaps you tried to do that and ran into problems. But if there are problems replacing the default one, then making it configurable is even more problematic.

Anyway... these are my quick thoughts without digging deeply into this.

@pionxzh
Copy link
Contributor Author

pionxzh commented Jan 11, 2024

Ok, I see your point. Will try to replace the parser.

@pionxzh
Copy link
Contributor Author

pionxzh commented Jan 13, 2024

See #355

@pionxzh pionxzh closed this Jan 13, 2024
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.

recast with espree failed on new.target
2 participants