Skip to content

Commit

Permalink
Adds pre-commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
jvrsantacruz committed May 28, 2024
1 parent 4f12e1d commit c1ae1b8
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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}}}"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
=========

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 99

0 comments on commit c1ae1b8

Please sign in to comment.