Skip to content

Commit 09a5f83

Browse files
feat: add ESLint, markdownlint, validators, and tests to pre-commit hook
Pre-commit now mirrors CI checks locally: build, ESLint, markdownlint, all 6 validators, and test suite. Prevents CI failures from reaching GitHub.
1 parent 579ee44 commit 09a5f83

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

β€Ž.githooks/pre-commitβ€Ž

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/usr/bin/env bash
2-
# pre-commit hook β€” rebuild all derived content, fail if unstaged changes detected.
2+
# pre-commit hook β€” mirrors CI checks locally before commit.
33
#
4-
# Ensures .cursor/skills/, .cursor/agents/, and .cursor/rules/
5-
# are always in sync with their sources before any commit.
4+
# Runs: build, lint (ESLint + markdownlint), validators, and tests.
5+
# Ensures .cursor/ generated files stay in sync with sources.
66
#
77
# Setup: git config core.hooksPath .githooks
8+
# Skip: git commit --no-verify (emergency only)
89

910
set -euo pipefail
1011

12+
# ── 1. Build ────────────────────────────────────────────────────────────────
1113
echo "[pre-commit] Running build..."
1214
npm run build --silent 2>/dev/null
1315

@@ -27,3 +29,36 @@ if [ -n "$CHANGED" ]; then
2729
fi
2830

2931
echo "[pre-commit] Build verified β€” all generated files in sync."
32+
33+
# ── 2. ESLint ───────────────────────────────────────────────────────────────
34+
echo "[pre-commit] Running ESLint..."
35+
if ! npx eslint . --quiet 2>/dev/null; then
36+
echo ""
37+
echo "[pre-commit] ESLint failed. Fix errors above and try again."
38+
exit 1
39+
fi
40+
echo "[pre-commit] ESLint passed."
41+
42+
# ── 3. markdownlint ────────────────────────────────────────────────────────
43+
echo "[pre-commit] Running markdownlint..."
44+
if ! npx markdownlint '**/*.md' --ignore node_modules 2>/dev/null; then
45+
echo ""
46+
echo "[pre-commit] markdownlint failed. Run 'npx markdownlint --fix' to auto-fix."
47+
exit 1
48+
fi
49+
echo "[pre-commit] markdownlint passed."
50+
51+
# ── 4. CI validators ───────────────────────────────────────────────────────
52+
echo "[pre-commit] Running validators..."
53+
node scripts/ci/validate-agents.js && \
54+
node scripts/ci/validate-commands.js && \
55+
node scripts/ci/validate-skills.js && \
56+
node scripts/ci/validate-hooks.js && \
57+
node scripts/ci/validate-install-manifests.js && \
58+
node scripts/ci/validate-no-personal-paths.js
59+
echo "[pre-commit] Validators passed."
60+
61+
# ── 5. Tests ────────────────────────────────────────────────────────────────
62+
echo "[pre-commit] Running tests..."
63+
node tests/run-all.js
64+
echo "[pre-commit] All checks passed."

0 commit comments

Comments
Β (0)