Menu

1 / 2

Stop arguing about formatting in code reviews. Use Husky and lint-staged instead.

DEV Community·Mohamed Idris·6 months ago
#uc5MELWx
#webdev#javascript#git#productivity#beginners
Reading 0:00
15s threshold

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…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.