Using Prettier and husky to make your commits safe.
Whether you work in a team or by yourself, having consistently formatted code is important for readability and maintainability.
Tl;dr
Use Prettier to automatically format your JavaScript and use husky and lint-staged to add a precommit script that runs Prettier and your tests when you commit.
Check out the full code:
ESLint vs JavaScript Standard Style vs Prettier
For JavaScript there are solutions like ESLint that can check if your code is consistent. But ESLint requires a lot of configuration and while it can fix some things by itself, it often requires manual intervention when you screw up.
Then there is JavaScript Standard Style. This module is the complete opposite of ESLint. It requires no configuration and can also fix some of your code by itself. But having no configuration, it’s very opinionated.
And now there is also Prettier. The difference between Prettier and other lint tools is that Prettier doesn’t check your code. It just takes your code as input and spits out formatted code as output. Like JavaScript Standard Style, Prettier is opinionated but you have some…