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

Support a way to run Scalafmt on the build files #1751

Closed
lolgab opened this issue Feb 23, 2022 · 4 comments · Fixed by #2719 or #2720
Closed

Support a way to run Scalafmt on the build files #1751

lolgab opened this issue Feb 23, 2022 · 4 comments · Fixed by #2719 or #2720
Milestone

Comments

@lolgab
Copy link
Member

lolgab commented Feb 23, 2022

Is there a way to lint the build files?
In my projects I usually define a target like:

def buildSources = T.sources(os.pwd / "build.sc")

And then I run Scalafmt with:

mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll buildSources

It would be nice if there was a way to access the build sources without having to define them manually.

@lefou
Copy link
Member

lefou commented Feb 23, 2022

Currently there is no such target, but I think it is a good idea to have it. It should probably also contain all included files, which we need also in other places like e.g. IDE/BSP support.

@lefou
Copy link
Member

lefou commented May 4, 2022

I opened a RFC which might affect this issue.

@lefou
Copy link
Member

lefou commented Aug 31, 2023

I opened two PR to support running targets on meta-builds (#2719) and to look up the .scalafmt.conf in the current working directory (#2720). After merging both, the following should work to format the build.sc and it's included files:

$ mill --meta-level 1 mill.scalalib.scalafmt.ScalafmtModule/reformatAll sources
Formatting 3 Scala sources
parsed config (v3.7.10): /home/lefou/work/opensource/mill/.scalafmt.conf

@lolgab
Copy link
Member Author

lolgab commented Sep 1, 2023

Thank you very much for this @lefou! 👏👏👏👏

@lefou lefou added this to the 0.11.3 milestone Sep 2, 2023
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