Common code formatters and linters in a single Nix flake.
As a prerequisite, you need Nix to use this flake. You can integrate it into a flake as in this example. To use it ad hoc instead, run
nix run --no-write-lock-file github:evolutics/travel-kit -- [argument …]To format your code and check for linting errors, simply run
# WARNING: this overwrites original files.
travel-kitThis affects all Git-tracked files in the current folder and its subfolders (recursively). Alternatively, you can pass specific paths to only affect those.
A non-zero exit status is returned if the formatting has been changed or there are linting errors.
To not apply certain tools, use the --skip option.
The --dry-run option shows what would be done without changing anything.
The following tools are integrated:
-
git diff --check 'HEAD^' -- *
-
gitlint --ignore body-is-missing
-
hadolint -- *.Dockerfile Dockerfile -
htmlhint -- *.htm *.html
-
jsonnet-lint -- *.jsonnet *.libsonnet
-
pylint -- *.py -
shellcheck -- *.sh -
stylelint -- *.css -
treefmt --fail-on-change --no-cache --walk filesystem *.bazel *.bzl *.cjs *.clj *.cljc *.cljs *.cljx *.css *.go *.html *.js *.json *.json5 *.jsonnet *.jsx *.libsonnet *.md *.mdx *.mjs *.nix *.pkr.hcl *.pkrvars.hcl *.py *.pyi *.rb *.scss *.sh *.sql *.tf *.tftest.hcl *.tfvars *.toml *.ts *.tsx *.vue *.yaml *.yml *Vagrantfile