From 9739865559d2b0a5d8955ad3121db48da6ac6aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 8 Jun 2021 22:54:38 +0300 Subject: [PATCH] feat: Add pre-commit integration --- .pre-commit-hooks.yaml | 7 +++++++ README.md | 2 ++ docs/pre-commit.md | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 .pre-commit-hooks.yaml create mode 100644 docs/pre-commit.md diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..4db3bc3 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,7 @@ +- id: typos + name: typos + description: Source code spell checker + language: rust + entry: typos + args: [--write-changes] + types: [text] diff --git a/README.md b/README.md index 338ab81..179b181 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Dual-licensed under [MIT](LICENSE-MIT) or [Apache 2.0](LICENSE-APACHE) - [False Positives](#false-positives) - [Integrations](#integrations) - [GitHub Action](docs/github-action.md) + - [pre-commit](docs/pre-commit.md) - [Custom](#custom) - [Debugging](#debugging) - [Reference](docs/reference.md) @@ -87,6 +88,7 @@ extend-exclude = ["localized/*.po"] ### Integrations - [GitHub Actions](docs/github-action.md) +- [pre-commit](docs/pre-commit.md) #### Custom diff --git a/docs/pre-commit.md b/docs/pre-commit.md new file mode 100644 index 0000000..e23e5dc --- /dev/null +++ b/docs/pre-commit.md @@ -0,0 +1,21 @@ +# pre-commit + +To use `typos` with [`pre-commit`](https://pre-commit.com), point its +config at this repository: + +```yaml +repos: + - repo: https://github.com/crate-ci/typos + rev: v1.0.6 + hooks: + - id: typos +``` + +Be sure to change `rev` to use the desired `typos` git tag or +revision. + +The hook configuration defaults to writing fixes, which triggers a +`pre-commit` failure if any files are modified. To make it report its +findings only instead, override the hook's `args` with something that +does not contain `-w`/`--write-changes`, for example `[]` (meaning +pass no options).