-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
88 lines (81 loc) · 3.4 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
88 lines (81 loc) · 3.4 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
86
87
88
# .pre-commit-config.yaml
#
# What this does
# --------------
# Runs automated checks/formatters:
# - whitespace / EOF hygiene
# - YAML syntax validation (MkDocs config often needs --unsafe)
# - Markdown formatting (MkDocs-friendly; keeps admonition indentation sane)
# - Python lint (with safe auto-fixes) + Python formatting (Ruff)
#
# Typical workflow
# ----------------
# First run may "fail" because some hooks MODIFY files (by design):
# pre-commit run --all-files
# git add -A
# pre-commit run --all-files
# Running hooks on all files is an official pre-commit usage pattern.
#
# Path note (Windows)
# -------------------
# pre-commit matches file paths using git-style forward slashes (/), even on Windows.
# REPO-WIDE EXCLUSIONS (APPLIES TO *ALL* HOOKS)
# --------------------------------------------
# pre-commit's `exclude` takes a SINGLE regular expression string.
# The top-level `exclude` is applied to all hooks.
#
# Excluded FOLDERS:
# - ontologies/ (and all its sub-folders, including ontologies/versioned/)
# - vocabulary/ (and all its sub-folders)
# - docs/deliverables/ (generated exports)
# Excluded FILES:
# - LICENSE-*.md (license variants)
# - *.tsv (tabular exports)
# - docs/method/specification-vocabulary.html (generated HTML)
exclude: ^(ontologies/|vocabulary/|docs/deliverables/|LICENSE-.*\.md$|.*\.tsv$|docs/method/specification-vocabulary\.html$)
repos:
# ---------------------------------------------------------------------------
# 1) Universal hygiene checks (fast and low-risk)
# ---------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
# Removes trailing whitespace at end of lines.
- id: trailing-whitespace
# Ensures files end with a newline.
- id: end-of-file-fixer
# YAML validation.
# --unsafe: parse syntax without "loading" YAML, enabling extensions/unsafe constructs
# (useful for MkDocs configs with python tags / custom constructors).
- id: check-yaml
args: [--unsafe]
# ---------------------------------------------------------------------------
# 2) Markdown formatting (MkDocs-friendly)
# ---------------------------------------------------------------------------
- repo: https://github.com/hukkin/mdformat
rev: 1.0.0
hooks:
- id: mdformat
# Only run on Markdown files.
files: \.(md|mdx)$
# Plugins installed inside the hook venv:
# - mdformat-mkdocs: MkDocs/MkDocs-Material friendly formatting; keeps 4-space indents.
args: [--number]
additional_dependencies:
- mdformat-gfm
- mdformat-frontmatter
- mdformat-mkdocs==5.1.4
- mdformat-footnote==0.1.3
# ---------------------------------------------------------------------------
# 3) Python lint + format (Ruff)
# ---------------------------------------------------------------------------
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.1
hooks:
# Lint first (and auto-fix where safe), then format.
# Ruff recommends placing the lint hook before the formatter when using --fix.
- id: ruff-check
args: [--fix]
types_or: [python, pyi]
- id: ruff-format
types_or: [python, pyi]