Skip to content

chore: migrate plugins to tsquery #1009

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

Closed
wants to merge 15 commits into from

Conversation

beaussan
Copy link
Contributor

@beaussan beaussan commented Mar 27, 2025

Migrate:

  • astro
  • next
  • tanstack router

to tsquery to do ast lookup. I didn't to sst given I don't know enough the source file expected shape

This website also help you live debug your tsquery queries: https://tsquery-playground.firebaseapp.com/

@beaussan beaussan changed the base branch from main to feat/plugin-ast March 27, 2025 08:25
Copy link

pkg-pr-new bot commented Mar 27, 2025

Open in Stackblitz

npm i https://pkg.pr.new/knip@1009

commit: d6a4883

@webpro
Copy link
Member

webpro commented Mar 27, 2025

Thanks, @beaussan! This is super useful to compare bare TS and tsquery side by side.

To be honest, personally I don't find the new queries more readable over bare TS. I think I'd rather write it out and have a bit more flexibility. On the other hand, there's also something to say for not having to call ts.forEachChild and visit.

Happy to have others chime in as well, as I'm a bit on the fence here. It's another thing to learn for folks, or perhaps it's actually preferred over bare TS, idk :)

@beaussan
Copy link
Contributor Author

This is super useful to compare bare TS and tsquery side by side.

That's the goal!

To be honest, personally I don't find the new queries more readable over bare TS. I think I'd rather write it out and have a bit more flexibility. On the other hand, there's also something to say for not having to call ts.forEachChild and visit.

Happy to have others chime in as well, as I'm a bit on the fence here. It's another thing to learn for folks, or perhaps it's actually preferred over bare TS, idk :)

Totally understandable, at work we have to do a lot of ast based analysis of code files, we started with the same visitor pattern but we end up refactoring to the tsquery pattern a year back and it helped a lot with the maintainability, but it's a tradeoff that only you + team only can consider!

Feel free to close the pr if it's not relevant ✂️

@webpro webpro force-pushed the feat/plugin-ast branch 3 times, most recently from ce5a619 to 079263b Compare April 8, 2025 07:09
@webpro
Copy link
Member

webpro commented Apr 8, 2025

Thanks again Nicolas. I'm going to close this one in favor of implementing resolveAST functions with typescript and some helpers only. We can always reconsider in the future.

@webpro webpro closed this Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants