scalacenter / scalafix

Refactoring and linting tool for Scala
https://scalacenter.github.io/scalafix/
BSD 3-Clause "New" or "Revised" License
821 stars 186 forks source link

scalafix-codegen sbt-plugin? #1674

Open armanbilge opened 1 year ago

armanbilge commented 1 year ago

Sorry, yet-another-upstream-idea 😁

The idea is basically to turn this example project into a plugin: https://github.com/olafurpg/scalafix-codegen/blob/7fdaa50a94cc31ae7af2d2237c91bc9611b17fe1/build.sbt

I know it's a small snippet, but after copying it between a few projects gets old fast. So it would be cool to add it as a small plugin to sbt-scalafix, would that be of interest?

bjaglin commented 1 year ago

Sorry, yet-another-upstream-idea grin

Keep them coming! I don't have a bandwidth to actively contribute these weeks (I have been reactive mostly), but I am definitely open to reviews.

I know it's a small snippet, but after copying it between a few projects gets old fast. So it would be cool to add it as a small plugin to sbt-scalafix, would that be of interest?

For sure, a ScalafixCodegenPlugin would be nice. Happy to see the scenarios you use it for, and maybe discuss how the plugin would work for a client here in this issue before going to implementation mode. https://github.com/hamnis/dataclass-scalafix/blob/main/readme.md is also derived from the same snippet, taking into account semantic rules (I suspect/hope we can remove the need for 2 separate projects by making ScalafixCodegenPlugin & ScalafixPlugin coordinate somehow).

armanbilge commented 1 year ago

Awesome, thanks! We are using it for generating sources from GraphQL schema. And possibly in the future for enhancing Scala.js facades as well. https://github.com/gemini-hlsw/explore/blob/14af551f7fc3e0f51404b0b56b975f013924867f/build.sbt#L125-L137

Thanks for the pointer to the other example, we are also currently using the two-project setup. That's interesting about removing the need for that, I didn't realize that could be possible. Interesting :)

In lieu of discussion here I might put up a draft PR, I don't understand the pieces here well enough without actually playing with the code.