diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..24c5ca0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +# reference: https://verdantfox.com/blog/view/how-to-use-git-pre-commit-hooks-the-hard-way-and-the-easy-way +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-json + - id: check-yaml + args: + - --unsafe + - id: double-quote-string-fixer + - id: end-of-file-fixer + - repo: https://github.com/golangci/golangci-lint + rev: v1.52.2 + hooks: + - id: golangci-lint + - repo: local + hooks: + - id: gofmt-fixer + name: gofmt + entry: gofmt -w . + language: golang + types: [go] + # - id: check-x + # name: Check X + # entry: ./bin/check-x.sh + # language: script + # files: \.x$ diff --git a/docs/contribute.md b/docs/contribute.md index 3e32c23..5e461f8 100644 --- a/docs/contribute.md +++ b/docs/contribute.md @@ -14,6 +14,17 @@ Before you start any Pull Request, `it is recommended that you create an issue` `Pull Requests` can only be merged once all status checks are green. +### Pre-commit Hook + +This repo uses [pre-commit hook](https://github.com/pre-commit/pre-commit-hooks) to apply linting check prior to writing commit to local git history. To set up pre-commit, do the followings: + +```bash +# install pre-commit +pip3 install pre-commit +# install pre-commit hooks +pre-commit install +``` + ### How to make a clean pull request - Create a `personal fork` of the project on Github.