Lesson 11 / 25
Formatting Standards & Team Consistency
Use Prettier to enforce uniform code style across your team.
Why formatting matters
Inconsistent formatting wastes time in code reviews (arguing over spaces vs. tabs). Prettier removes this debate: it's opinionated and automatic.
Run Prettier on save
Configure your editor to run Prettier on save for automatic formatting.
# In VS Code settings.json:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
Output:
Prettier configured to format on save in VS Code
Distributed consistency
Commit .prettierrc to your repo. When all developers use the same config, Prettier ensures identical formatting regardless of editor settings.
Quick check
Quick check: Why commit .prettierrc to git?
- So all team members format code identically.
- To speed up Prettier.
- To disable Prettier for some files.
Answer
So all team members format code identically. — Shared .prettierrc ensures consistent formatting across the team, eliminating style arguments in code reviews.