-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
85 lines (77 loc) · 3.23 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
85 lines (77 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# pre-commit configuration — single source of truth for fast, deterministic lint.
# Local hooks front-load these checks before push; the `pre-commit` CI job
# (.github/workflows/quality.yml) runs the same config as the enforcement gate.
#
# Setup (see CONTRIBUTING.md):
# pipx install pre-commit
# pre-commit install # installs both pre-commit and pre-push hooks
#
# Hook tools reuse the repo's existing config files (_typos.toml, .markdownlint.jsonc,
# rustfmt.toml) — no settings are duplicated here.
#
# One exception, and it is not optional: pre-commit invokes hooks with an explicit list of
# file paths, which bypasses every exclusion a tool applies while *walking* a tree. `typos`
# honours `[files] extend-exclude` in _typos.toml and skips dotted directories only when it
# does the walking itself; hand it `docs/mermaid.min.js` by name and it checks it anyway.
# The vendored and generated files therefore have to be excluded here as well.
# Vendored or generated content that no hook may rewrite:
# - docs/mermaid*.js — vendored mdbook-mermaid assets, regenerated by `mdbook-mermaid install .`
# - docs/book/ — mdBook output (gitignored, but present in a local working tree)
# - Cargo.lock — cargo-generated
# Reformatting any of these produces a diff against upstream that the next regeneration undoes.
exclude: |
(?x)^(
docs/mermaid\.min\.js|
docs/mermaid-init\.js|
docs/book/.*|
Cargo\.lock
)$
# `pre-commit install` wires up both stages in one command.
default_install_hook_types: [pre-commit, pre-push]
# Pin to the same toolchain CI uses; the local fmt/clippy hooks honour rust-toolchain.toml.
minimum_pre_commit_version: "3.5.0"
repos:
# --- General file hygiene (commit stage) ---
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-merge-conflict
- id: mixed-line-ending
args: [--fix=lf]
# --- Spell check (commit stage) — reads _typos.toml ---
- repo: https://github.com/crate-ci/typos
rev: v1.45.2
hooks:
- id: typos
# --- Markdown lint (commit stage) — reads .markdownlint.jsonc ---
# Scoped to mdBook source, excluding SUMMARY.md (multiple H1 part-titles are by design),
# matching the previous Docs workflow step.
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.18.1
hooks:
- id: markdownlint-cli2
files: ^docs/src/.*\.md$
exclude: ^docs/src/SUMMARY\.md$
# --- Rust hooks (local; honour rust-toolchain.toml) ---
# CI skips these via `SKIP: fmt,clippy` — the lightweight pre-commit job has no
# toolchain; rust.yml runs cargo fmt --check / clippy where the cache lives.
- repo: local
hooks:
- id: fmt
name: cargo fmt
entry: cargo fmt --all --
language: system
types: [rust]
pass_filenames: false
stages: [pre-commit]
- id: clippy
name: cargo clippy
entry: cargo clippy --all-targets --all-features -- -D warnings
language: system
types: [rust]
pass_filenames: false
# pre-push only: a full clippy build is too heavy for every commit.
stages: [pre-push]