|
| 1 | +default_language_version: |
| 2 | + python: python3 |
| 3 | + |
| 4 | +repos: |
| 5 | + ############################################################################# |
| 6 | + # Misc |
| 7 | + ############################################################################# |
| 8 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 9 | + rev: v4.5.0 |
| 10 | + hooks: |
| 11 | + - id: check-ast # Validates the syntax of Python files. |
| 12 | + - id: check-case-conflict # Identifies potential case-insensitive file name conflicts. |
| 13 | + - id: check-merge-conflict # Searches for merge conflict markers within files. |
| 14 | + - id: check-symlinks # Detects broken symlinks. |
| 15 | + - id: check-added-large-files # Blocks commits that add large files. Default limit is 500kB. |
| 16 | + # Can be configured with args, e.g., '--maxkb=1000' to change the limit. |
| 17 | + # Files in 'your_dir/' can be excluded. |
| 18 | + # exclude: 'your_dir/.*' |
| 19 | + # args: ['--maxkb=5000'] |
| 20 | + - id: end-of-file-fixer # Ensures files end with a single newline or are empty. |
| 21 | + - id: trailing-whitespace # Removes any trailing whitespace at the end of lines. |
| 22 | + |
| 23 | + ############################################################################# |
| 24 | + # JSON, TOML |
| 25 | + ############################################################################# |
| 26 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 27 | + rev: v4.5.0 |
| 28 | + hooks: |
| 29 | + - id: check-json # Validates JSON files to ensure they are properly formatted and syntactically correct. |
| 30 | + types: [json] |
| 31 | + - id: check-toml # Checks TOML files for errors and format issues to ensure valid syntax. |
| 32 | + types: [toml] |
| 33 | + |
| 34 | + ############################################################################# |
| 35 | + # Shell |
| 36 | + ############################################################################# |
| 37 | + - repo: https://github.com/jumanjihouse/pre-commit-hooks |
| 38 | + rev: 3.0.0 |
| 39 | + hooks: |
| 40 | + - id: shfmt # Formats shell scripts to a standard convention using shfmt. |
| 41 | + - id: shellcheck # Lints shell scripts to identify syntax and usage errors, with a specified severity of 'warning'. |
| 42 | + args: |
| 43 | + - --severity=warning |
| 44 | + |
| 45 | + ############################################################################# |
| 46 | + # Python |
| 47 | + ############################################################################# |
| 48 | + - repo: https://github.com/PyCQA/autoflake |
| 49 | + rev: v2.2.1 |
| 50 | + hooks: |
| 51 | + - id: autoflake # Removes unused imports and unused variables from Python code |
| 52 | + args: |
| 53 | + - --in-place |
| 54 | + - --remove-all-unused-imports |
| 55 | + |
| 56 | + - repo: https://github.com/pycqa/isort |
| 57 | + rev: 5.12.0 |
| 58 | + hooks: |
| 59 | + - id: isort # Sorts Python imports into sections and by alphabetical order |
| 60 | + args: |
| 61 | + - --settings-path |
| 62 | + - .cpa/pyproject.toml |
| 63 | + types: |
| 64 | + - python |
| 65 | + |
| 66 | + - repo: https://github.com/psf/black |
| 67 | + rev: 23.10.1 |
| 68 | + hooks: |
| 69 | + - id: black # Formats Python code to conform to the Black code style |
| 70 | + args: |
| 71 | + - --config |
| 72 | + - .cpa/pyproject.toml |
| 73 | + types: |
| 74 | + - python |
| 75 | + |
| 76 | + - repo: https://github.com/pycqa/flake8 |
| 77 | + rev: 6.1.0 |
| 78 | + hooks: |
| 79 | + - id: flake8 # Lints Python code for errors and code style issues based on PEP8 |
| 80 | + args: |
| 81 | + - --config=.cpa/flake8.cfg |
| 82 | + types: |
| 83 | + - python |
| 84 | + |
| 85 | + # - repo: https://github.com/astral-sh/ruff-pre-commit |
| 86 | + # # Ruff version. |
| 87 | + # rev: v0.0.270 |
| 88 | + # hooks: |
| 89 | + # - id: ruff |
| 90 | + |
| 91 | + # - repo: https://github.com/python-poetry/poetry |
| 92 | + # rev: '1.4.0' |
| 93 | + # hooks: |
| 94 | + # # https://python-poetry.org/docs/master/pre-commit-hooks/ |
| 95 | + # # These hooks ensure that our dependencies are being updated only thru poetry. |
| 96 | + # - id: poetry-check # Makes sure the poetry configuration does not get committed in a broken state. |
| 97 | + # # - id: poetry-lock # Makes sure the lock file is up-to-date when committing changes. |
| 98 | + |
| 99 | + ############################################################################# |
| 100 | + # CSS, Markdown, JavaScript, TypeScript, YAML style formatter |
| 101 | + ############################################################################# |
| 102 | + - repo: https://github.com/pre-commit/mirrors-prettier |
| 103 | + rev: v3.0.3 |
| 104 | + hooks: |
| 105 | + - id: prettier |
| 106 | + name: prettier |
| 107 | + entry: prettier |
| 108 | + args: [--config, .cpa/prettier.json, --write] |
| 109 | + types_or: |
| 110 | + - javascript |
| 111 | + - ts |
| 112 | + - tsx |
| 113 | + - scss |
| 114 | + - css |
| 115 | + - yaml |
| 116 | + - markdown |
| 117 | + exclude: templates/.pre-commit-config.yaml |
| 118 | + |
| 119 | + ## |
| 120 | + # Rust |
| 121 | + ## |
| 122 | + - repo: https://github.com/doublify/pre-commit-rust |
| 123 | + rev: v1.0 |
| 124 | + hooks: |
| 125 | + - id: fmt # Formats Rust code using rustfmt |
| 126 | + - id: cargo-check # Checks Rust code for compilation errors and warnings |
| 127 | + - id: clippy # Lints Rust code with clippy for common mistakes and style issues |
0 commit comments