mill
mill copied to clipboard
Support a way to run Scalafmt on the build files
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.
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.
I opened a RFC which might affect this issue.
- https://github.com/com-lihaoyi/mill/discussions/1857
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
Thank you very much for this @lefou! 👏👏👏👏