chore: add pre-commit guardrails
PR Check / Dockerfile lint (droast) (pull_request) Skipped
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / ESLint (pull_request) Successful in 34s
PR Check / Typecheck (pull_request) Successful in 37s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 8s
PR Check / AI code review (opencode) (pull_request) Failing after 11s
PR Check / Dockerfile lint (droast) (pull_request) Skipped
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / ESLint (pull_request) Successful in 34s
PR Check / Typecheck (pull_request) Successful in 37s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 8s
PR Check / AI code review (opencode) (pull_request) Failing after 11s
- gitleaks: block secrets before they enter history - pre-commit-hooks: whitespace/eof hygiene, yaml/json/toml checks, merge-conflict markers, large files, private keys - commitizen (commit-msg stage): enforce conventional commits so release-please always sees releaseable messages - actionlint: validate workflow files offline - eslint --fix on staged files (local hook, needs pnpm install)
This commit is contained in:
1 parent
c70f5d7963
commit
ab7626d5f7
1 file changed
+74
@@ -0,0 +1,74 @@
|
|||||||
|
# Pre-commit guardrails — deterministic checks that run before every commit.
|
||||||
|
# Cheap things live here (seconds); slow things (typecheck, build, tests,
|
||||||
|
# Snyk, AI review) stay in CI (.gitea/workflows/pr-checker.yml).
|
||||||
|
#
|
||||||
|
# One-time setup per machine:
|
||||||
|
# pre-commit install # pre-commit stage
|
||||||
|
# pre-commit install --hook-type commit-msg # commit-msg stage (release-please!)
|
||||||
|
# pre-commit run --all-files # first full pass
|
||||||
|
#
|
||||||
|
# ARM64 + x86_64 both supported by every hook below.
|
||||||
|
|
||||||
|
repos:
|
||||||
|
# ---------------------------------------------------------------- gitleaks
|
||||||
|
# Block secrets before they enter history. CI scans history too (gitleaks
|
||||||
|
# job), but this prevents the commit from ever existing.
|
||||||
|
- repo: https://github.com/gitleaks/gitleaks
|
||||||
|
rev: v8.30.1
|
||||||
|
hooks:
|
||||||
|
- id: gitleaks
|
||||||
|
|
||||||
|
# -------------------------------------------------- basic file hygiene ---
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v6.0.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: mixed-line-ending
|
||||||
|
args: [--fix=lf]
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-json
|
||||||
|
- id: check-toml
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-added-large-files
|
||||||
|
args: [--maxkb=1024]
|
||||||
|
- id: detect-private-key
|
||||||
|
|
||||||
|
# ------------------------------------------------ conventional commits ---
|
||||||
|
# release-please silently ignores non-conventional messages, so a bad
|
||||||
|
# subject line means "no release and no idea why". This makes it
|
||||||
|
# impossible. Runs on the commit-msg stage, not pre-commit.
|
||||||
|
- repo: https://github.com/commitizen-tools/commitizen
|
||||||
|
rev: v4.19.2
|
||||||
|
hooks:
|
||||||
|
- id: commitizen
|
||||||
|
stages: [commit-msg]
|
||||||
|
|
||||||
|
# ---------------------------------------------------- workflow linting ---
|
||||||
|
# Validates .gitea/workflows syntax and ${{ }} expressions - the class of
|
||||||
|
# bug that hashFiles-skipping and broken YAML came from.
|
||||||
|
- repo: https://github.com/rhysd/actionlint
|
||||||
|
rev: v1.7.12
|
||||||
|
hooks:
|
||||||
|
- id: actionlint
|
||||||
|
files: \.gitea/workflows/.*\.ya?ml$
|
||||||
|
|
||||||
|
# --------------------------------------------------------- ESLint (Nuxt) -
|
||||||
|
# Local hook: needs `pnpm install` to have run in this repo. --fix makes
|
||||||
|
# it a helper; only staged files are linted (fast).
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: eslint
|
||||||
|
name: eslint --fix (staged files)
|
||||||
|
entry: bash -c 'pnpm exec eslint --fix'
|
||||||
|
language: system
|
||||||
|
files: \.(vue|ts|js|mjs|cjs)$
|
||||||
|
types: [file]
|
||||||
|
|
||||||
|
# When Go services arrive, add:
|
||||||
|
# - repo: https://github.com/dnephin/pre-commit-golang
|
||||||
|
# rev: <latest>
|
||||||
|
# hooks:
|
||||||
|
# - id: go-fmt
|
||||||
|
# - id: go-imports
|
||||||
|
# - id: golangci-lint # or go-vet for a lighter pass
|
||||||
Reference in new issue
Block a user