diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6a57d1f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,68 @@ +--- +default_stages: [pre-commit] +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + # Attempts to load all json files to verify syntax. + - id: check-json + + # Prettify JSON files + - id: pretty-format-json + args: [--autofix, --indent=4, --no-sort-keys] + + # Check for files that contain merge conflict strings. + - id: check-merge-conflict + + # Attempts to load all TOML files to verify syntax. + - id: check-toml + + # Makes sure files end in a newline and only a newline. + - id: end-of-file-fixer + stages: [pre-commit, manual] + + # Replaces or checks mixed line ending. + - id: mixed-line-ending + args: [--fix=no] + + # Trims trailing whitespace. + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + stages: [pre-commit, manual] + + # Sorts entries in requirements.txt + - id: requirements-txt-fixer + + # Sort imports + - repo: https://github.com/timothycrosley/isort + rev: 5.12.0 + hooks: + - id: isort + args: [--profile=black] + + # Fix common misspellings in source code + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + entry: codespell --write-changes + + # Fast Python linter + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.1.6 + hooks: + - id: ruff + args: [--target-version, "py312"] + + # Shell script linter + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.9.0.6 + hooks: + - id: shellcheck + + # YAML linter + - repo: https://github.com/adrienverge/yamllint + rev: v1.33.0 + hooks: + - id: yamllint + args: [--config-data, "{extends: relaxed, rules: {line-length: {max: 100}}}"] diff --git a/README.md b/README.md index 2aa0fe4..0b3c71f 100644 --- a/README.md +++ b/README.md @@ -351,6 +351,10 @@ Install the application and run tests in development: pip install -e . python -m pytest +Make sure to install pre-commit before checking in any changes: + + pre-commit install + Changelog ========= diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..57a5583 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 99