Add support for pre-commit
authorPierre Le Marre <dev@wismill.eu>
Thu, 28 Sep 2023 07:39:52 +0000 (09:39 +0200)
committerWismill <dev@wismill.eu>
Fri, 29 Sep 2023 07:42:08 +0000 (09:42 +0200)
See https://pre-commit.com for further info. Current checks:

- Whitespaces
- Yaml
- Large files
- Python linting/formatting

TODO: investigate options for C linter and formatter

.pre-commit-config.yaml [new file with mode: 0644]

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644 (file)
index 0000000..e58a098
--- /dev/null
@@ -0,0 +1,28 @@
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
+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-yaml
+  - id: check-added-large-files
+- repo: https://github.com/psf/black
+  rev: 23.9.1
+  hooks:
+  - id: black
+    args: ['--check', '--diff', '.']
+- repo: https://github.com/charliermarsh/ruff-pre-commit
+  rev: v0.0.291
+  hooks:
+  - id: ruff
+    # ambiguous-variable-name (E741), line-too-long (E501)
+    args: ['--ignore=E741,E501', '.']
+# [TODO] C linter/formatter
+# Note: There is an old config file for uncrustify (https://uncrustify.sourceforge.net)
+# in the repo, but we may want to migrate to other modern style.
+# - repo: https://github.com/pre-commit/mirrors-clang-format
+#   rev: v16.0.6
+#   hooks:
+#   - id: clang-format