|
1 | 1 | ci: |
2 | | - autofix_prs: false |
| 2 | + # pre-commit.ci (https://pre-commit.ci) — free for open-source repos. |
| 3 | + # When enabled, it runs all hooks on every PR and commits any auto-fixes |
| 4 | + # back to the PR branch automatically (no local setup required for contributors). |
| 5 | + # Hooks that can auto-fix: end-of-file-fixer, trailing-whitespace, |
| 6 | + # mixed-line-ending, markdownlint (--fix), codespell (--write-changes). |
| 7 | + # Hooks that only detect (still require a human fix): check-yaml, |
| 8 | + # check-merge-conflict, rstcheck, yamllint. |
| 9 | + autofix_prs: true |
3 | 10 | autoupdate_schedule: 'quarterly' |
| 11 | + # rstcheck needs a full Sphinx/Poetry environment that pre-commit.ci |
| 12 | + # doesn't have — skip it there and let docs.yml in GitHub Actions cover it. |
| 13 | + skip: [rstcheck] |
| 14 | + |
4 | 15 | repos: |
| 16 | + # --------------------------------------------------------------------------- |
| 17 | + # General file hygiene |
| 18 | + # --------------------------------------------------------------------------- |
5 | 19 | - repo: https://github.com/pre-commit/pre-commit-hooks |
6 | 20 | rev: v5.0.0 |
7 | 21 | hooks: |
8 | | - - id: check-added-large-files |
9 | | - args: ['--maxkb=1000'] |
10 | | - - id: detect-aws-credentials |
11 | | - args: [--allow-missing-credentials] |
12 | | - - id: detect-private-key |
13 | | - - id: mixed-line-ending |
14 | | - - id: trailing-whitespace |
15 | | - - id: no-commit-to-branch |
16 | | - args: [--branch, main] |
| 22 | + - id: check-added-large-files # block files > 1 MB |
| 23 | + args: ['--maxkb=1000'] |
| 24 | + - id: check-case-conflict # catch Mac/Windows case insensitivity bugs |
| 25 | + - id: check-merge-conflict # catch leftover <<<< ==== >>>> markers |
| 26 | + - id: check-yaml # validate all YAML files (workflows, config) |
| 27 | + - id: detect-aws-credentials |
| 28 | + args: [--allow-missing-credentials] |
| 29 | + - id: detect-private-key |
| 30 | + - id: end-of-file-fixer # ensure every file ends with a newline |
| 31 | + - id: mixed-line-ending |
| 32 | + - id: no-commit-to-branch |
| 33 | + args: [--branch, main] |
| 34 | + - id: trailing-whitespace |
| 35 | + # --markdown-linebreak-ext preserves intentional two-space line breaks in .md |
| 36 | + args: [--markdown-linebreak-ext=md] |
| 37 | + |
| 38 | + # --------------------------------------------------------------------------- |
| 39 | + # Markdown linting |
| 40 | + # Config: .markdownlint.yaml (mirrors the existing .mdl_style.rb exclusions) |
| 41 | + # markdownlint-cli2 is the official CLI maintained by the markdownlint author (DavidAnson). |
| 42 | + # --------------------------------------------------------------------------- |
| 43 | + - repo: https://github.com/DavidAnson/markdownlint-cli2 |
| 44 | + rev: v0.19.1 |
| 45 | + hooks: |
| 46 | + - id: markdownlint-cli2 |
| 47 | + # --fix auto-corrects issues with a safe mechanical fix. |
| 48 | + # Issues requiring human judgement are still reported as errors. |
| 49 | + args: [--fix, --config, .markdownlint.yaml] |
| 50 | + |
| 51 | + # --------------------------------------------------------------------------- |
| 52 | + # reStructuredText validation (toctree, directives, broken references) |
| 53 | + # --------------------------------------------------------------------------- |
| 54 | + - repo: https://github.com/rstcheck/rstcheck |
| 55 | + rev: v6.2.4 |
| 56 | + hooks: |
| 57 | + - id: rstcheck |
| 58 | + additional_dependencies: ['rstcheck-core', 'sphinx'] |
| 59 | + args: [--report-level=warning] |
| 60 | + |
| 61 | + # --------------------------------------------------------------------------- |
| 62 | + # YAML linting — catches style issues in workflow files and config |
| 63 | + # Config: .yamllint.yaml |
| 64 | + # --------------------------------------------------------------------------- |
| 65 | + - repo: https://github.com/adrienverge/yamllint |
| 66 | + rev: v1.35.1 |
| 67 | + hooks: |
| 68 | + - id: yamllint |
| 69 | + args: [--config-file, .yamllint.yaml] |
| 70 | + |
| 71 | + # --------------------------------------------------------------------------- |
| 72 | + # Spell checking (.md, .rst, .yml, .yaml) |
| 73 | + # --------------------------------------------------------------------------- |
17 | 74 | - repo: https://github.com/codespell-project/codespell |
18 | 75 | rev: v2.4.1 |
19 | 76 | hooks: |
20 | 77 | - id: codespell |
21 | | - files: ^.*\.(md|rst|yml)$ |
| 78 | + files: ^.*\.(md|rst|ya?ml)$ |
| 79 | + args: |
| 80 | + # --write-changes auto-corrects unambiguous spelling mistakes. |
| 81 | + # Ambiguous corrections (multiple candidates) are still reported. |
| 82 | + - --write-changes |
| 83 | + # nd/ND = Creative Commons "No Derivatives" |
| 84 | + # SORCE = Solar Radiation and Climate Experiment (NASA mission) |
| 85 | + # sav = IDL save file extension |
| 86 | + - --ignore-words-list=nd,ND,SORCE,sav |
0 commit comments