github jdx/hk v2.9.0
v2.9.0: OpenTofu validation builtin and shfmt formatting for zsh startup files

3 hours ago

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_validate builtin (#1766, @illesnagy1). This builtin runs tofu validate once in each directory that contains changed *.tf, *.tfvars, *.tf.json, *.tofu, *.tofu.json or .terraform.lock.hcl files. It skips anything under .terraform/. If validation fails on a module that hasn't been initialized, it runs tofu init -backend=false -input=false and validates again. The builtin is a POSIX shell script, so on Windows you need to set shell to a POSIX shell.

    hooks {
      ["pre-commit"] {
        steps {
          ["tofu_validate"] = Builtins.tofu_validate
        }
      }
    }
  • shfmt formats zsh startup files and zsh-shebang scripts (#1759, @sahidvelji). hk now gives the zsh and shell types to .zshenv, .zprofile, .zshrc, .zlogin and .zlogout based on their filenames. It does the same for those names without the leading dot (zshrc and so on), which is how many dotfiles repos store them. The shfmt builtin now matches the zsh type as well as sh and bash. 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 shell files. If a custom step selects types = List("shell") and runs a tool that can't handle zsh, that step will start receiving zsh startup files.

Changed

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 hk builds 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.

Don't miss a new hk release

NewReleases is sending notifications on new releases.