spacewander commented on a change in pull request #3624:
URL: https://github.com/apache/apisix/pull/3624#discussion_r626339640



##########
File path: CONTRIBUTING.md
##########
@@ -51,9 +51,47 @@ Once we've discussed your changes and you've got your code 
ready, make sure that
 
 ## Contribution Guidelines for Documentation
 
+* pre-commit
+
+    A framework for managing and maintaining multi-language pre-commit hooks.
+    Pre-commit can be [installed](https://pre-commit.com/#installation) with 
`pip`, `curl`, `brew` or `conda`.
+    You need to first install pre-commit and then install the pre-commit hooks 
with `pre-commit install`.
+    Now pre-commit will run automatically on git commit!
+
+    It's usually a good idea to run the hooks against all the files when 
adding new hooks (usually pre-commit will only run on the changed files during 
git hooks).
+    Use `pre-commit run --all-files` to check all files.
+
+    To run a single hook use `pre-commit run --all-files <hook_id>`
+
+    To update use `pre-commit autoupdate`
+
+    * [Quick start](https://pre-commit.com/#quick-start)
+    * [Usage](https://pre-commit.com/#usage)
+    * [pre-commit-autoupdate](https://pre-commit.com/#pre-commit-autoupdate)
+
+* Spell Checking
+
+    We are running [misspell](https://github.com/client9/misspell) which is 
mainly written in
+    [Golang](https://golang.org/) to check spelling with [GitHub 
Actions](.github/workflows/lint.yml). Correct
+    commonly misspelled English words quickly with `misspell`. `misspell` is 
different from most other spell checkers
+    because it doesn't use a custom dictionary. You can run `misspell` locally 
against all files with:
+
+    Notable `misspell` help options or flags are:
+
+    - `-i` string: ignore the following corrections, comma separated
+    - `-w`: Overwrite file with corrections (default is just to display)
+
+    We also run [codespell](https://github.com/codespell-project/codespell) 
with `pre-commit` to check spelling and
+    [codespell](https://pypi.org/project/codespell/) runs against a [small 
custom dictionary](codespell.txt).
+    `codespell` is written in [Python](https://www.python.org/) and you can 
run it with:
+
+    ```bash
+    codespell --ignore-words=codespell.txt 
--skip="./docs/ar,./docs/es,./docs/zh,./.git,./**/*.crt,./**/go.sum"

Review comment:
       Could we remove this so that we don't need to maintain two versions of 
codespell? People can know how to run it by reading the CI setup.

##########
File path: .pre-commit-config.yaml
##########
@@ -0,0 +1,72 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+---
+default_stages: [commit, push]
+default_language_version:
+  # force all unspecified Python hooks to run python3
+  python: python3
+minimum_pre_commit_version: "1.20.0"
+repos:
+  - repo: meta
+    hooks:
+      - id: identity
+      - id: check-hooks-apply
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v3.4.0
+    hooks:
+      - id: check-case-conflict
+      - id: check-json
+      - id: check-merge-conflict
+      - id: check-xml
+      - id: check-yaml
+      - id: end-of-file-fixer
+      - id: fix-byte-order-marker
+      - id: mixed-line-ending
+      - id: trailing-whitespace
+        exclude: ^t/node/remote-addr-ipv6.t$
+  # - repo: git://github.com/Lucas-C/pre-commit-hooks
+  #  rev: v1.1.9
+  #  hooks:
+  #    - id: forbid-tabs
+  #    - id: remove-tabs
+  - repo: https://github.com/codespell-project/codespell
+    rev: v2.0.0
+    hooks:
+      - id: codespell
+        name: Check Spelling with codespell
+        entry: codespell --ignore-words=codespell.txt
+        exclude: ^docs/ar|^docs/es|^docs/zh|^.git|^.*\.crt$|^.*\.sum$

Review comment:
       It would be easier to maintain if you use an allow list. There are many 
things in the `.gitignore` that need to be excluded.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to