From 6e15ca5000f476a9c06d08fc66fe065ade82af96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 2 May 2020 20:59:20 +0300 Subject: [PATCH 1/2] Add pre-commit hook config, https://pre-commit.com Use -w by default so that the pre-commit hook works like an autofixer. Co-Authored-By: Max Gautier --- .pre-commit-hooks.yaml | 8 ++++++++ 1 file changed, 8 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..5319a75 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,8 @@ +- id: misspell + name: misspell + description: Correct commonly misspelled English words... quickly + language: golang + entry: misspell + args: + - -w + - -error From 8592a4eff1c7c6b88e4e862f9fe09656b399e6fc Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Wed, 22 May 2024 10:08:11 +0200 Subject: [PATCH 2/2] Document pre-commit hook usage --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 514727f..d2c3e75 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,23 @@ Usage of misspell: -w Overwrite file with corrections (default is just to display) ``` +### Pre-commit hook + +To use misspell with [pre-commit](https://pre-commit.com/), add the following to your `.pre-commit-config.yaml`: + + +```yaml +- repo: https://github.com/golangci/misspell + rev: v0.6.0 + hooks: + - id: misspell + # The hook will run on all files by default. + # To limit to some files only, use pre-commit patterns/types + # files: + # exclude: + # types: +``` + ## FAQ * [Automatic Corrections](#correct)