Skip to content

Commit 9560a34

Browse files
committed
add precommit
1 parent e717167 commit 9560a34

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# ============================================================
2+
# .pre-commit-config.yaml (Lean Hygiene)
3+
# ============================================================
4+
# VARIANT: lean-hygiene
5+
# SOURCE: https://github.com/denisecase/templates
6+
#
7+
# REQ: Lean repos MAY include a .pre-commit-config.yaml for repo hygiene (optional).
8+
# WHY: Keep diffs clean across OSes and validate repo metadata files (TOML/YAML/JSON).
9+
#
10+
# OBS: These hooks use and do NOT override:
11+
# - .editorconfig (whitespace / indentation)
12+
# - .gitattributes (EOL normalization)
13+
# - tool configs (if present), e.g., lakefile.lean, pyproject.toml
14+
#
15+
# OPTIONAL LOCAL USAGE (no repo venv required):
16+
# Install uv (once, user-level).
17+
# uv self update
18+
# uvx pre-commit install
19+
# uvx pre-commit run --all-files (just once, to check all files)
20+
# Subsequent commits will AUTOMATICALLY run pre-commit hooks after git add
21+
# and before git commit.
22+
#
23+
# NOTE: pre-commit is optional.
24+
# Repositories do NOT require Python, uv, or pre-commit to clone or commit.
25+
26+
exclude: |
27+
(?x)^(
28+
\.DS_Store|
29+
\.coverage|
30+
\.ipynb_checkpoints/|
31+
\.mypy_cache/|
32+
\.nox/|
33+
\.pytest_cache/|
34+
\.ruff_cache/|
35+
\.tox/|
36+
\.venv/|
37+
.*\.(egg-info)/|
38+
.*\.log|
39+
__pycache__/|
40+
_minted.*/|
41+
build/|
42+
coverage\.xml|
43+
dist/|
44+
htmlcov/|
45+
lake-packages/|
46+
node_modules/|
47+
out/|
48+
site/
49+
)
50+
51+
repos:
52+
# === REPO: PRE-COMMIT HOOKS (cross-platform, zero config) ===
53+
#
54+
# These hooks prevent problems that show up later as:
55+
# - mysterious diffs
56+
# - broken builds on another OS
57+
58+
- repo: https://github.com/pre-commit/pre-commit-hooks
59+
rev: v6.0.0
60+
hooks:
61+
# === PRE-COMMIT: NORMALIZE FILE FORMATTING ===
62+
63+
- id: trailing-whitespace
64+
name: A1) Clean trailing whitespace (per .editorconfig)
65+
args: [--markdown-linebreak-ext=md] # Preserves markdown double-space line breaks
66+
67+
- id: end-of-file-fixer
68+
name: A2) End files with a newline (per .gitattributes)
69+
70+
- id: mixed-line-ending
71+
name: A3) Normalize line endings to LF before linters
72+
args: [--fix=lf] # OBS: Windows working copies may be CRLF.
73+
74+
# === PRE-COMMIT: CHECK DATA FILE FORMATS ===
75+
76+
- id: check-json
77+
name: B1) Validate JSON syntax
78+
79+
- id: check-toml
80+
name: B2) Validate TOML syntax
81+
82+
- id: check-yaml
83+
name: B3) Validate YAML syntax
84+
files: \.(yml|yaml)$
85+
exclude: ^mkdocs\.ya?ml$ # OBS: mkdocs.yaml may include non-standard tags.
86+
87+
# === PRE-COMMIT:CHECK FOR COMMON PROBLEMS ===
88+
89+
- id: check-added-large-files
90+
name: C1) Prevent accidental commits of large binaries
91+
args: [--maxkb=500]
92+
93+
- id: check-merge-conflict
94+
name: C2) Prevent committing merge conflicts
95+
96+
- id: check-case-conflict
97+
name: C3) Check for filename case conflicts
98+
99+
# === GLOBAL SETTINGS ===
100+
# ALT: Set fail_fast to true to stop at first failure.
101+
fail_fast: false # Run all hooks even if one fails

0 commit comments

Comments
 (0)