The pre-coursier
make it easy to run JVM tools on pre-commit.
The following tools must be installed:
- pre-commit >= 2.8.0
- coursier
Add the following to your .pre-commit-config.yaml
:
repos: - repo: https://github.com/junghoon-vans/pre-coursier rev: v0.2.0 hooks: - id: scalafmt args: ["--config-str", "version = 3.7.14, runner.dialect = scala3"]
pre-commit install
git add . # Add changes
git commit -m "Run pre-commit"
This will run scalafmt
on all *.scala|*.sc|*.sbt
files.
By default, the version of the hook is set to the latest
version.
This feature is only available for libraries in coursier default channel and requires pre-commit 3.0.0+.
If you want to override the version of the hook, you can set the version of the hook to run with the additional_dependencies
option.
repos: - repo: https://github.com/junghoon-vans/pre-coursier rev: v0.2.0 hooks: - id: scalafmt args: ["--config-str", "version = 2.4.2, runner.dialect = scala3"] additional_dependencies: ["scalafmt:2.4.2"] # Override the version