From 60af7e9880fe8e3d44984ab63fece6d1661700b8 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Mon, 5 Dec 2022 21:45:54 +1300 Subject: [PATCH] feat: Provide pre-commit hook configuration and docs --- .pre-commit-hooks.yaml | 7 +++++++ README.md | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..53dfe13 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,7 @@ +- id: deadnix + name: deadnix + description: Scan Nix files for dead code + entry: deadnix + args: [--fail] + types: [nix] + language: system diff --git a/README.md b/README.md index e445c4b..38c3b3a 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,26 @@ Warning: Unused declarations were found. $ nix run github:astro/deadnix -- -eq test.nix ``` +## Usage with [pre-commit](https://pre-commit.com/) + +Add the following to your project's `.pre-commit-config.yaml`: +```yaml +repos: + - repo: https://github.com/astro/deadnix + rev: ID # frozen: VERSION + hooks: + - id: deadnix + #args: [--edit] # Uncomment to automatically modify files + stages: [commit] +``` + +Replace `ID` and `VERSION` above with the relevant version tag and +commit ID for reference, for example: + +```yaml +rev: da39a3ee5e6b4b0d3255bfef95601890afd80709 # frozen: v1.2.3 +``` + ## Behavior ### Renaming of all unused to lambda args to start with `_`