hk 2.9.0 adds a tofu_validate builtin for OpenTofu, and the shfmt builtin now formats zsh startup files and scripts that have a zsh shebang. It is also the first release since 2.7 that installs with cargo install hk, because the 2.8.2 crate was never published.
Added
-
tofu_validatebuiltin (#1766, @illesnagy1). This builtin runstofu validateonce in each directory that contains changed*.tf,*.tfvars,*.tf.json,*.tofu,*.tofu.jsonor.terraform.lock.hclfiles. It skips anything under.terraform/. If validation fails on a module that hasn't been initialized, it runstofu init -backend=false -input=falseand validates again. The builtin is a POSIX shell script, so on Windows you need to setshellto a POSIX shell.hooks { ["pre-commit"] { steps { ["tofu_validate"] = Builtins.tofu_validate } } }
-
shfmtformats zsh startup files and zsh-shebang scripts (#1759, @sahidvelji). hk now gives thezshandshelltypes to.zshenv,.zprofile,.zshrc,.zloginand.zlogoutbased on their filenames. It does the same for those names without the leading dot (zshrcand so on), which is how many dotfiles repos store them. Theshfmtbuiltin now matches thezshtype as well asshandbash. This means it picks up these files, plus extensionless scripts that start with#!/bin/zsh, without any extra globs. To format zsh files you need shfmt 3.13.1 or newer.These files now count as
shellfiles. If a custom step selectstypes = List("shell")and runs a tool that can't handle zsh, that step will start receiving zsh startup files.
Changed
terraform_docsnow picks up*.tf.jsonmodules (#1766, @illesnagy1).
Fixed
- The crate is published to crates.io again (#1770, @jdx). The publish job for v2.8.2 failed, so that version never reached crates.io. 2.9.0 is published with the generated Pkl package included, so
cargo install hkbuilds work offline in the same way as the prebuilt release binaries.
Full Changelog: v2.8.2...v2.9.0
💚 Sponsor hk
hk is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.
If hk speeds up your pre-commit loop or makes linting less painful, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep hk fast, free, and independent.