If your team has ever left a comment like "missing semicolon" or "wrong quote style" on a pull request, this post is for you.
Formatting is not a code review topic. It should be handled automatically before the code even reaches a PR. Here is how to do that cleanly using Husky and lint-staged.
What are we actually solving?
The problem is simple: developers format code differently, editors have different defaults, and without enforcement, you end up with inconsistent style that creates noisy diffs and unnecessary review comments.
The goal is to auto-format and auto-lint staged files right before every commit, so bad formatting never reaches the repo.
Two tools make this easy:
Prettier handles formatting (spacing, quotes, semicolons, line length)
ESLint handles code quality (unused variables, missing dependencies, bad patterns)
Husky lets you run scripts automatically on git events like pre-commit
lint-staged runs those scripts only on staged files, not your entire codebase
Running tools on the full…