Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

chore(frontend): Phase 5 §8.5 — add pre-commit ESLint guard

Juan Denisbdffd9136178
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 00000000..0301c6a8
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,26 @@
+#!/bin/sh
+# ServerKit pre-commit hook — lints staged frontend JS/JSX and blocks the commit
+# on ESLint ERRORS only (warnings are allowed). It exits early for commits that
+# touch no frontend JS/JSX (backend, SCSS, docs), so it never gets in the way of
+# those. Enable once per clone with:
+#
+# git config core.hooksPath .githooks
+#
+# (Or run frontend/setup-hooks.sh.)
+
+files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^frontend/src/.*\.(js|jsx)$' || true)
+[ -z "$files" ] && exit 0
+
+cd frontend || exit 0
+# Skip silently if deps aren't installed yet (don't fetch/block).
+[ -d node_modules ] || exit 0
+
+rel=$(echo "$files" | sed 's#^frontend/##')
+echo "$rel" | xargs npx eslint
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo ""
+ echo "✖ Commit blocked: fix the ESLint error(s) above (warnings are allowed)."
+ echo " To bypass for an emergency commit: git commit --no-verify"
+fi
+exit $status
diff --git a/AGENTS.md b/AGENTS.md
index 33d0c66c..027a72db 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -101,6 +101,11 @@ ServerKit deploys on Linux (bare metal, VPS, or Docker). Development may happen
- One logical change per commit
- Minimal, focused diffs — don't silently refactor surrounding code
- Branch naming: `feature/`, `fix/`, `docs/`, `refactor/` prefixes
+- **Pre-commit hook**: a shared git hook (`.githooks/pre-commit`) lints staged
+ frontend JS/JSX and blocks the commit on ESLint **errors** (warnings allowed;
+ backend/SCSS-only commits are skipped). Enable once per clone:
+ `git config core.hooksPath .githooks` (or `sh frontend/setup-hooks.sh`). Keep
+ the repo at **0 ESLint errors**.
## Styling Standard
diff --git a/frontend/setup-hooks.sh b/frontend/setup-hooks.sh
new file mode 100644
index 00000000..3e4ca90d
--- /dev/null
+++ b/frontend/setup-hooks.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Enable the repo's shared git hooks (pre-commit ESLint guard).
+# Run once after cloning: sh frontend/setup-hooks.sh
+cd "$(git rev-parse --show-toplevel)" || exit 1
+git config core.hooksPath .githooks
+echo "✓ core.hooksPath set to .githooks — pre-commit ESLint guard is active."