Formatting
| Prettier concept | |
| Few options | |
| Format on save | |
| End style fights |
Prettier concept
Prettier is an opinionated formatter. You write code any way you like, it rewrites the file into one canonical layout. Debates about commas and quotes end because the tool decides.
The command below is shown as text only so you can recognize it in docs. No install step is shown here.
npx prettier .
formatted file list is reported
Few options
Prettier works best with almost no configuration. Most teams set only quotes and line width, then accept every other default without discussion.
Fewer options mean fewer debates and faster reviews. Diffs stay small because only real logic changes, never whitespace noise.
{
"singleQuote": false,
"printWidth": 100,
"trailingComma": "all"
}
Format on save
The real win is automation. Turn on format on save in the editor so every file is normalized the moment you save it.
After a week you stop thinking about layout entirely. Hands write logic, the tool handles alignment, and commits stay clean by default.
function fullName(first: string, last: string): string {
return "Name: " + first + " " + last;
}
End style fights
Code review should discuss design, not brace placement. Agree once that formatted output is always correct, then never comment on style again.
Newcomers onboard faster too. They run the formatter and instantly match house style with zero tribal knowledge.
const users: string[] = ["Ada", "Grace"];
const upper = users.map((u) => u.toUpperCase());
console.log(upper);
Next: Debugging
Article author: Arthur Isaev