Husky Pipeline

Wiring BookNest's Husky and Lint-Staged Pipeline

Sam now makes Husky 35,333 's pre-commit run lint-staged 14,736 , moves the commit-msg hook under Husky, drops the hand pre-commit hook (ESLint 39,810 catches syntax errors and more), commits, and tries the pipeline on a typo:

Committing the hook pipeline and watching it stop a bad commitShell
echo "npx lint-staged" > .husky/pre-commit
git mv .githooks/commit-msg .husky/commit-msg && git rm -q .githooks/pre-commit
git add . && git commit -qm "Lint staged JavaScript with ESLint before each commit"
git push -q
# Edit app.js: a typo, "res.json(row)" in GET /api/genres
git commit -qam "Return the genre list"; echo "exit status $?"
git restore --staged --worktree app.js
Output
...
⋯ Reverting to original state because of errors…
...
✖ eslint --fix --max-warnings=0:
/home/dev/v5-ch2/booknest/app.js
  69:15  error  'rows' is assigned a value but never used  no-unused-vars
  72:16  error  'row' is not defined                       no-undef
✖ 2 problems (2 errors, 0 warnings)
husky - pre-commit script failed (code 1)
exit status 1

The first commit passed; lint-staged linted its one staged JavaScript file, eslint.config.js. The second was stopped by two real errors, the kind of typo that otherwise surfaces as a 500 error in production. A fresh clone now gets both hooks from npm 2,036 install alone, and the configured whitespace hook still runs from Sam's local configuration. Keep this stage under a few seconds; slow checks such as BookNest's database tests belong in pre-push or, better, in CI (GitHub), where nobody can skip them.