Enforce Code Quality with Husky & Biome in Node.js/TypeScript

Enforcing code quality on every commit with Husky + Biome in a Node.js/TypeScript project. Here's the exact setup I use in my Express + Prisma API ). The problem Git hooks solve Git has no opinion on code quality. Without automation, broken imports, formatting drift, and lint errors silently enter your history. Git hooks run scripts before Git records a commit — if the script exits with code 1, the commit is aborted. The catch: raw hooks live in .git/hooks/ which is not tracked by version control. Every developer must configure them manually. Husky fixes this by pointing core.hooksPath to a .husky/ directory that is tracked by Git. Hooks are automatically installed for every dev on bun install via the prepare script. Tool stack Husky v9 — Git hook manager (~2kb, zero dependencies) Biome v2 — Replaces ESLint + Prettier in one tool. Lints and formats TypeScript in a single pass. Setup (3 commands) bun add --dev husky bunx husky init # Adds "prepare": "husky" to package.json automatically .husky/pre-commit: bunx --bun @biomejs/biome check --write . --write auto-fixes formatting. Exits code 1 on unfixable lint errors → commit blocked. How the exit code logic works git commit → Husky runs .husky/pre-commit → Exit 0: commit proceeds → Exit 1: commit aborted Husky is purely an enforcer. The actual checking is done by whatever script you run. Bypassing when needed HUSKY=0 git commit -m "wip: draft" Use only on feature branches. Never bypass on main. What to add next Once you have test files, extend the hook: bunx --bun @biomejs/biome check --write . bun test Start with pure utility tests (no DB dependencies) — auth helpers, response formatters, validators. Stack: Express 5 · Prisma · TypeScript · Bun · Biome #nodejs #typescript #devtools #backend #javascript #softwareengineering #webdevelopment

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories