Просмотр исходного кода

Add pre-commit .yaml with hooks

Add description and pre-commit hooks in the way that it is be used.
metya 5 лет назад
Родитель
Сommit
c2fcc0fd16
2 измененных файлов с 110 добавлено и 2 удалено
  1. 92 0
      .pre-commit-config.yaml
  2. 18 2
      README.md

+ 92 - 0
.pre-commit-config.yaml

@@ -0,0 +1,92 @@
+repos:
+-   hooks:
+    -   id: commitizen
+        stages:
+        - commit-msg
+    repo: https://github.com/commitizen-tools/commitizen
+    rev: v2.3.1
+
+
+-   hooks:
+    -   id: gitlint
+        stages: [commit-msg]
+    repo: https://github.com/jorisroovers/gitlint
+    rev: v0.13.1
+
+
+-   repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v3.1.0
+    hooks:
+    -   id: trailing-whitespace
+    -   id: end-of-file-fixer
+    -   id: check-docstring-first
+    # -   id: check-json
+    -   id: check-yaml
+    -   id: debug-statements
+    # -   id: name-test-test
+    # -   id: requirements-txt-fixer
+    -   id: double-quote-string-fixer
+
+-   repo: https://gitlab.com/pycqa/flake8
+    rev: 3.8.3
+    hooks:
+    -   id: flake8
+        additional_dependencies: [flake8-typing-imports==1.6.0]
+        args: [--config, .flake8]
+
+-   repo: https://github.com/pre-commit/mirrors-autopep8
+    rev: v1.5.3
+    hooks:
+    -   id: autopep8
+
+-   repo: https://github.com/asottile/pyupgrade
+    rev: v2.6.2
+    hooks:
+    -   id: pyupgrade
+        args: [--py36-plus]
+
+-   repo: https://github.com/asottile/reorder_python_imports
+    rev: v2.3.0
+    hooks:
+    -   id: reorder-python-imports
+        args: [--py3-plus]
+
+-   repo: https://github.com/asottile/add-trailing-comma
+    rev: v2.0.1
+    hooks:
+    -   id: add-trailing-comma
+        args: [--py36-plus]
+
+-   repo: https://github.com/asottile/setup-cfg-fmt
+    rev: v1.10.0
+    hooks:
+    -   id: setup-cfg-fmt
+
+-   repo: https://github.com/pre-commit/mirrors-mypy
+    rev: v0.782
+    hooks:
+    -   id: mypy
+
+-   repo: meta
+    hooks:
+    -   id: check-hooks-apply
+    -   id: check-useless-excludes
+
+
+# TALISMAN SECRETS CHECKER TWO OPTIONS - LOCALLY INSTALLED (commenterd) OR AS USUAL
+# -   repo: local
+#     hooks:
+#     -   id: talisman-precommit
+#         name: talisman
+#         entry: bash -c 'if [ -n "${TALISMAN_HOME:-}" ]; then ${TALISMAN_HOME}/talisman_hook_script pre-commit; else echo "TALISMAN does not exist. Consider installing from https://github.com/thoughtworks/talisman . If you already have talisman installed, please ensure TALISMAN_HOME variable is set to where talisman_hook_script resides, for example, TALISMAN_HOME=${HOME}/.talisman/bin"; fi'
+#         language: system
+#         pass_filenames: false
+#         types: [text]
+#         verbose: true
+
+-   repo: https://github.com/thoughtworks/talisman
+    rev: ''  # Update me!
+    hooks:
+    # either `commit` or `push` support
+    -   id: talisman-commit
+        # -   id: talisman-push

+ 18 - 2
README.md

@@ -1,2 +1,18 @@
-# useful-pre-commits
-bunch of pre-commit hooks with pre-commit python package
+# useful-pre-commits
+
+bunch of pre-commit hooks with pre-commit python package
+
+There are links on originally repositories:
+
+- https://github.com/pre-commit/pre-commit-hooks - original repo python package built-in hooks
+- https://github.com/commitizen-tools/commitizen - to lint gitmessage
+  - to use need to do `pre-commit install --hook-type commit-msg`
+- https://github.com/jorisroovers/gitlint - the same
+- https://gitlab.com/pycqa/flake8 - to check code style
+- https://github.com/pre-commit/mirrors-autopep8 - the same
+- https://github.com/asottile/pyupgrade - to check new versions of hooks
+- https://github.com/asottile/reorder_python_imports - to sort imports
+- https://github.com/asottile/add-trailing-comma - to add trailing comma
+- https://github.com/pre-commit/mirrors-mypy - to lint code and typings with mypy linter
+- https://github.com/thoughtworks/talisman/ - to check secrets in commits
+  - may to be installed locally or used as usually