From e24b1241fb372999b1ea1dd56fb168873df39972 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 30 Apr 2026 21:02:00 +0200 Subject: [PATCH] docs: Add pre-commit hook setup instructions for type validation Document optional local Git pre-commit hook configuration to catch type drift before commits. Also document Husky alternative. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Docs/Web-Development.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Docs/Web-Development.md b/Docs/Web-Development.md index 0aff173..7cd32f2 100644 --- a/Docs/Web-Development.md +++ b/Docs/Web-Development.md @@ -111,6 +111,34 @@ The script returns: - **Exit 2:** Backend is not accessible (set `BANGUI_BACKEND_URL` if needed) - **Exit 3:** Type generation failed +### Pre-Commit Hook Setup (Local Development) + +To catch type drift locally before committing, set up a Git pre-commit hook: + +1. **Create `.git/hooks/pre-commit`:** + ```bash + #!/bin/bash + # Validate types before commit + cd frontend + npm run validate:types + if [ $? -ne 0 ] && [ $? -ne 2 ]; then # Allow hook to skip if backend unavailable + echo "❌ Types out of sync. Run 'npm run generate:types' and commit the changes." + exit 1 + fi + ``` + +2. **Make it executable:** + ```bash + chmod +x .git/hooks/pre-commit + ``` + +3. **Alternative: Use Husky** (if your project has Husky configured) + ```bash + npx husky add .husky/pre-commit "cd frontend && npm run validate:types" + ``` + +**Note:** The pre-commit hook is optional and local only. The CI/CD pipeline will always validate types, so types cannot drift even without a local hook. + --- ## 3. Type Safety in API Calls