After some time spent, I have a pre-commit configuration that works fine for me. I decided to use husky with lint-staged, which I configure in package.json.
In project.clj I’ve added the following to install zprint and use it from lein:
(defproject my-project "0.1.0-SNAPSHOT"
; Use zprint.
:dependencies [
; ...
[zprint "0.5.3"]]
; Make it run by CLI command: lein zprint.
:plugins [
; ...
[lein-zprint "0.5.3"]]
; Configure zprint.
:zprint {:old? false :style :respect-nl}
; ...
)
Also, I’ve added some configuration to prevent zprint from creating new files and to keeping the additional linebreak.
Unfortunately clj-kondo is not available as lein plugin, but I can use it as Node.js package. Here is my package.json configuration:
{
"devDependencies": {
"husky": "^3.1.0",
"lint-staged": "^10.0.0-beta.14",
"clj-kondo": "^2019.11.23"
},
"scripts": {
"format": "lein zprint",
"lint": "clj-kondo --lint"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{clj,cljs}": [
"npm run format",
"npm run lint"
]
}
}