feat(dx): pre-commit hooks for local CI (no remote needed)

Local quality gate that runs on every git commit:
- node --check syntax on staged .js files
- block on new emoji in staged .js/.html/.css (md files allowed)
- block on new console.log/debug/debugger statements
- backend route auth lint (existing npm run lint:routes)
- backend tests (baseline 3 fails, block if grew)

Install: npm run hooks:install (top-level)
Bypass: git commit --no-verify

Skips slow checks when irrelevant files changed (tests/lint only run
if backend touched).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-05-22 21:49:58 +03:00
parent 3135402dd7
commit 696049271f
5 changed files with 371 additions and 1 deletions
+17
View File
@@ -0,0 +1,17 @@
@echo off
rem install-hooks.cmd -- installs the LearnSpace pre-commit hook on Windows
rem Usage: scripts\install-hooks.cmd
rem Or via npm: npm run hooks:install
for /f "tokens=*" %%i in ('git rev-parse --show-toplevel') do set REPO=%%i
set HOOK=%REPO%\.git\hooks\pre-commit
(
echo #!/bin/sh
echo # LearnSpace pre-commit hook ^(auto-generated -- edit scripts/pre-commit.js^)
echo REPO="$(git rev-parse --show-toplevel)"
echo node "$REPO/scripts/pre-commit.js" ^|^| exit 1
) > "%HOOK%"
echo Pre-commit hook installed at: %HOOK%
echo Bypass anytime with: git commit --no-verify