Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

dixahq/scala-pre-commit-hooks

 
 

Repository files navigation

⚠️ This repository is archived. Instead of depending on this repository, define hooks locally in your .pre-commit-config.yaml.

repos:
  - repo: local
    hooks:
      - id: scalafmt
        name: scalafmt
        entry: bash -c 'scala-cli fmt -- "$@" && git add "$@"' --
        language: system
        files: '\.(scala|sbt)$'
        stages: [pre-commit]

This runs [scala-cli fmt](https://scala-cli.virtuslab.org/docs/commands/fmt/) when .scala or .sbt files are staged, then re-stages only those files. Works reliably with renames and deletions.

Legacy hooks (this repository)

The hooks below are still functional but no longer maintained.

  • sbt-fatal-warnings - turns on -Xfatal-warnings, runs a clean compilation on the given scope.

  • sbt-unused-imports - as above, but also adds the "unused imports" warning.

  • scalafmt-check - runs scalafmt --mode=changed --test.

  • scalafmt-autofix - runs scalafmt --mode=changed and automatically stages the reformatted files.

Known issue: --mode=changed fails when staged files include renames (git mv).

Legacy usage

repos:
  - repo: https://github.com/dixahq/scala-pre-commit-hooks
    rev: v0.9.2
    hooks:
      - id: scalafmt-autofix

About

Pre-commit/Pre-push hooks for Scala

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 76.1%
  • Shell 23.9%