|
| 1 | +# ============================================================ |
| 2 | +# .pre-commit-config.yaml (no Python) |
| 3 | +# ============================================================ |
| 4 | +# VARIANT: adaptive-no-python |
| 5 | +# Updated: 2026-05-05 |
| 6 | + |
| 7 | +# Fast, consistent repository hygiene before commit. |
| 8 | +# |
| 9 | +# These hooks complement and do not replace: |
| 10 | +# - .editorconfig |
| 11 | +# - .gitattributes |
| 12 | +# - pyproject.toml |
| 13 | +# |
| 14 | +# Local usage: |
| 15 | +# uv self update |
| 16 | +# uvx pre-commit install |
| 17 | +# uvx pre-commit run --all-files |
| 18 | + |
| 19 | +exclude: | |
| 20 | + (?x)^( |
| 21 | + \.DS_Store| |
| 22 | + \.coverage| |
| 23 | + \.ipynb_checkpoints/| |
| 24 | + \.mypy_cache/| |
| 25 | + \.nox/| |
| 26 | + \.pytest_cache/| |
| 27 | + \.ruff_cache/| |
| 28 | + \.tox/| |
| 29 | + \.venv/| |
| 30 | + .*\.(egg-info)/| |
| 31 | + .*\.log| |
| 32 | + __pycache__/| |
| 33 | + _minted.*/| |
| 34 | + build/| |
| 35 | + coverage\.xml| |
| 36 | + dist/| |
| 37 | + htmlcov/| |
| 38 | + lake-packages/| |
| 39 | + node_modules/| |
| 40 | + site/ |
| 41 | + ) |
| 42 | +
|
| 43 | +repos: |
| 44 | + # === REPO: PRE-COMMIT HOOKS (cross-platform, zero config) === |
| 45 | + # |
| 46 | + # These hooks prevent problems that show up later as: |
| 47 | + # - mysterious diffs |
| 48 | + # - broken builds on another OS |
| 49 | + |
| 50 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 51 | + rev: v6.0.0 |
| 52 | + hooks: |
| 53 | + # === PRE-COMMIT: NORMALIZE FILE FORMATTING === |
| 54 | + |
| 55 | + - id: trailing-whitespace |
| 56 | + name: A1) Clean trailing whitespace (per .editorconfig) |
| 57 | + args: [--markdown-linebreak-ext=md] # Preserves markdown double-space line breaks |
| 58 | + |
| 59 | + - id: end-of-file-fixer |
| 60 | + name: A2) End files with a newline (per .gitattributes) |
| 61 | + |
| 62 | + - id: mixed-line-ending |
| 63 | + name: A3) Normalize line endings to LF before linters |
| 64 | + args: [--fix=lf] # OBS: Windows working copies may be CRLF. |
| 65 | + |
| 66 | + # === PRE-COMMIT: CHECK DATA FILE FORMATS === |
| 67 | + |
| 68 | + - id: check-json |
| 69 | + name: B1) Validate JSON syntax (except .vscode/) |
| 70 | + # WHY: VSCode settings may include comments, which are non-standard JSON. |
| 71 | + exclude: ^\.vscode/.*\.json$ |
| 72 | + |
| 73 | + - id: check-toml |
| 74 | + name: B2) Validate TOML syntax |
| 75 | + |
| 76 | + - id: check-yaml |
| 77 | + name: B3) Validate YAML syntax |
| 78 | + files: \.(yml|yaml)$ |
| 79 | + # WHY: VS Code config files are editor-specific |
| 80 | + exclude: ^(\.vscode/) |
| 81 | + |
| 82 | + # === PRE-COMMIT:CHECK FOR COMMON PROBLEMS === |
| 83 | + |
| 84 | + - id: check-added-large-files |
| 85 | + name: C1) Prevent accidental commits of large binaries |
| 86 | + args: [--maxkb=500] |
| 87 | + |
| 88 | + - id: check-merge-conflict |
| 89 | + name: C2) Prevent committing merge conflicts |
| 90 | + |
| 91 | + - id: check-case-conflict |
| 92 | + name: C3) Check for filename case conflicts |
| 93 | + |
| 94 | + # === EXECUTE: LOCAL VALIDATION === |
| 95 | + |
| 96 | + - repo: local |
| 97 | + hooks: |
| 98 | + - id: markdownlint |
| 99 | + name: E1) Markdown lint |
| 100 | + # Uses .markdownlint-cli2.yaml if present, otherwise defaults. |
| 101 | + language: system |
| 102 | + entry: npx markdownlint-cli2 --fix |
| 103 | + pass_filenames: false |
| 104 | + always_run: true |
| 105 | + |
| 106 | +# === GLOBAL SETTINGS === |
| 107 | +# ALT: Set fail_fast to true to stop at first failure. |
| 108 | +fail_fast: false # Run all hooks even if one fails |
0 commit comments