# Generated by alef scaffold. Customize as needed.
default_install_hook_types:
- pre-commit
- commit-msg
exclude: ^target/|\.alef/
repos:
# Commit message linting
- repo: https://github.com/Goldziher/gitfluff
rev: {{ gitfluff }}
hooks:
- id: gitfluff-lint
args: ["--write"]
stages: [commit-msg]
# Shared hooks bundle — file safety, Rust (cargo-*, rustdoc,
# rust-max-lines), Markdown (rumdl), typos, and pyproject-fmt all live here.
- repo: https://github.com/kreuzberg-dev/pre-commit-hooks
rev: {{ shared_pre_commit_hooks }}
hooks:
# File safety
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-added-large-files
- id: detect-private-key
- id: check-json
- id: check-yaml
args: ["--allow-multiple-documents", "--unsafe"]
- id: check-toml
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: mixed-line-ending
- id: typos
args: ["--force-exclude"]
{% if has_python %}
# Python project surface
- id: pyproject-fmt
{% endif %}
# Rust — cargo-clippy with -D warnings subsumes cargo check
- id: cargo-fmt
args: ["--all"]
- id: cargo-clippy
args:
[
"--fix",
"--allow-dirty",
"--allow-staged",
"--workspace",
"--all-features",
{{ clippy_excludes }} "--all-targets",
"--",
"-D",
"warnings",
]
- id: cargo-sort
- id: cargo-machete
- id: cargo-deny
args: ["check"]
- id: rustdoc-lint
# Enforces a 1,000-line ceiling on .rs files; tests/ paths and tests.rs
# submodule files are excluded by default. Pass --include-tests to count
# them as well.
- id: rust-max-lines
args: ["--max=1000"]
# Markdown
- id: rumdl-fmt
{% if include_shared_hooks %}
# Optional per-repo extension repo (set scaffold.precommit.shared_hooks_repo
# in alef.toml to point at a fork or a sibling hooks repo).
- repo: {{ shared_hooks_repo }}
rev: {{ shared_hooks_rev }}
hooks:
- id: shfmt
- id: shellcheck
- id: hadolint
- id: textlint
{% endif %}
{% if include_alef_hooks %}
# Alef: generate READMEs, verify bindings, sync versions
{% if alef_hooks_are_local %}
- repo: local
hooks:
- id: alef-readme
name: alef readme
entry: alef readme
language: system
pass_filenames: false
- id: alef-verify
name: alef verify
entry: alef verify --exit-code
language: system
pass_filenames: false
- id: alef-sync-versions
name: alef sync versions
entry: alef sync-versions
language: system
pass_filenames: false
{% else %}
- repo: {{ alef_hooks_repo }}
rev: {{ alef_hooks_rev }}
hooks:
- id: alef-readme
- id: alef-verify
- id: alef-sync-versions
{% endif %}
{% endif %}