Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
33 lines
937 B
Bash
Executable File
33 lines
937 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Pre-commit: ESLint --fix + Prettier on staged files (via lint-staged).
|
|
# Auto-fixable issues are corrected and re-staged before the commit is created.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$ROOT"
|
|
|
|
if [[ "${SKIP_PRECOMMIT_CHECKS:-}" == "1" ]]; then
|
|
echo "⚠ SKIP_PRECOMMIT_CHECKS=1 — skipping pre-commit checks"
|
|
exit 0
|
|
fi
|
|
|
|
staged="$(git diff --cached --name-only --diff-filter=ACM || true)"
|
|
if [[ -z "$staged" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
if ! echo "$staged" | grep -qE '\.(js|jsx|ts|tsx|json|md|css|scss)$'; then
|
|
exit 0
|
|
fi
|
|
|
|
echo "Pre-commit: auto-fixing staged files (ESLint --fix, then Prettier)…"
|
|
before="$(git diff --cached --name-only || true)"
|
|
pnpm exec lint-staged
|
|
after="$(git diff --cached --name-only || true)"
|
|
|
|
if [[ "$before" != "$after" ]]; then
|
|
echo " Staging updated after auto-fix (review with git diff --cached if needed)."
|
|
fi
|
|
|
|
echo "✓ Pre-commit auto-fix passed"
|