A formatter automatically reformats source code according to rules agreed in a team style guide. It replaces subjective style debates with consistent, repeatable checks. section 4.2.3 section 5.3.1
Use a formatter at several points in development:
- Provide real-time feedback while developers write code. section 5.3.1
- Run it locally before committing changes. section 5.3.1
- Run it as a pull-request gate so reviewers can ignore failures of basic formatting. section 5.3.1
- Keep trivial style comments from blocking approval; define those approval rules separately in the team working agreement. section 4.2.3
Spacing between declarations and logic
A team may require a blank line between variable declarations and business logic. The formatter can enforce that choice consistently instead of relying on each developer to remember it. section 5.3.1
Listing 5.4 Line break spacing between variable declarations and logic (JavaScript)
function GetTotalDonutCalories() {
const donutLog = [
{ day: 'Monday', totalEaten: 2 },
{ day: 'Tuesday', totalEaten: 1 },
{ day: 'Wednesday', totalEaten: 3 },
{ day: 'Thursday', totalEaten: 2 },
{ day: 'Friday', totalEaten: 4 },
];
const caloriesConsumed = donutLog.reduce((lastCount, currentEntry));
return caloriesConsumed;
}
Inspect a JavaScript example that applies the agreed spacing between declarations and logic. section 5.3.1

