Repository navigation
Configuring a linter and a precommit hook to check formatting #21
mihalcea-bogdan-daniel
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Why Create a .prettierrc?
Prevents Inconsistent Formatting.
To avoid unnecessary formatting changes in commits, it's a good idea to add a .prettierrc config. This ensures consistent code styling across the team and prevents formatting conflicts.
Many projects also use Husky to lint commit messages, helping maintain a clean and structured Git history.
If one developer has tabWidth: 2 and another has tabWidth: 4, commits will keep changing indentation back and forth.
A .prettierrc ensures everyone follows the same rules.
Reduces Unnecessary Git Diffs
Without a fixed config, commits could include random formatting changes, making code reviews harder.
A consistent formatting style avoids unnecessary diffs.
Standardizes Formatting for Husky Pre-Commit Hooks
If Husky runs prettier --write, but different contributors have different settings, their commits might undo each other’s changes.
A shared .prettierrc keeps formatting the same for all developers.
All reactions