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

refactor 'leaky abstractions' related to ASTs + other AST utils into @wakaru/ast-utils #65

Closed
0xdevalias opened this issue Nov 29, 2023 · 5 comments
Labels

Comments

@0xdevalias
Copy link

Extracting this from a deeper comment in another issue so it doesn't get 'lost among the noise' there:

For my own reference, here are the code locations currently referencing jscodeshift, recast and/or ast-types:

I also note that there is a @wakaru/ast-utils package that could also potentially be used to centralise some 'leaky abstractions' from these libs if we were to refactor:

And it might also potentially make sense to refactor some of these utils into that ast-utils package as well maybe?

Originally posted by @0xdevalias in #32 (comment)

@0xdevalias 0xdevalias changed the title refactor 'leaky abstractions' related to AST's into @wakaru/ast-utils refactor 'leaky abstractions' related to ASTs + other AST utils into @wakaru/ast-utils Nov 29, 2023
@0xdevalias
Copy link
Author

I was just looking through some of the code again now, and this idea popped up in my mind again, so wanted to make sure to capture it as a proper issue.

Specifically I was looking at some of the util functions in unminify, and thinking they seemed generic enough that they might make sense to live in @wakaru/ast-utils:

Skimming through the code here, these are the ones that currently stand out to me as being both AST related, and seemingly generic enough that they could make sense to be refactored into @wakaru/ast-utils

@0xdevalias 0xdevalias mentioned this issue Nov 29, 2023
2 tasks
@pionxzh
Copy link
Owner

pionxzh commented Nov 30, 2023

This is how I usually work with them.

  • Implement a new rule
  • Extract utils
  • Used again in another rule -> move to utils folder
  • Used again and again
  • Refactor and categorize them -> Move to ast-utils

I will try to move some of them, but they will still follow this practice to grow the utils naturally.

@0xdevalias
Copy link
Author

This is how I usually work with them

@pionxzh That makes a lot of sense. Thanks for sharing your process :)

I will try to move some of them, but they will still follow this practice to grow the utils naturally.

@pionxzh nods yup, makes sense.

@0xdevalias
Copy link
Author

0xdevalias commented Dec 1, 2023

Stumbled across this AST lib (built on top of recast / babel) that offers some higher level AST helpers. Not sure if it would be useful directly, or just for some concepts/ideas, but figured I would link to it here in case it's useful:

@pionxzh
Copy link
Owner

pionxzh commented Dec 2, 2023

I have done the moving. I will check Magicast. Its proxy pattern looks quite convenient.

@pionxzh pionxzh closed this as completed Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants