Scenario
A teammate pastes a JavaScript snippet into chat as a single line and asks "does this look right?" Reviewing one-line code is a trap: the else branch, the object being sent, and the guard condition all blur together, and the reviewer approves the intent instead of the code. Format first — logic review only counts when you can see the control flow.
Broken input
if(user&&user.active){send({id:user.id,name:user.name})}else{throw new Error('inactive')}
Goal
Use Code Formatter to expand the snippet with Prettier before judging it. Formatting is semantically neutral, so anything that looks different afterwards was always there — you just could not see it.
Tool sequence
- Open Code Formatter.
- Paste the one-liner and format it as JavaScript.
- Read the expanded control flow: a guard on
user && user.active, asendwith a two-field object, and a throwing else branch. - Now review the logic questions the one-liner was hiding: should an inactive user really throw, and is
user.nameguaranteed whenuser.activeis true? - Post the formatted version back into the review thread so the discussion happens on readable code; if the snippet was HTML or SQL, the same first step applies via HTML Formatter or SQL Formatter.
Checkpoint output
if (user && user.active) {
send({ id: user.id, name: user.name });
} else {
throw new Error("inactive");
}
Branches, payload shape, and error path each sit on their own lines — the snippet is now reviewable, and the remaining questions are about behavior, not layout.
Common mistakes
- Reviewing logic while formatting noise is still in the way and approving what you assume the code says.
- Changing behavior while "cleaning up" — reformatting and refactoring are different operations.
- Forgetting to re-format after a small manual edit, so the version pasted back is half-styled.
- Formatting with different settings than the target repo and generating a spurious diff.
Related tools and lessons
- HTML Formatter - Format or minify HTML code.
- SQL Formatter - Format SQL queries with dialect-aware rules.
- JSON Formatter - Format, minify, and filter JSON by keys.
- Related lesson: Make Minified HTML Readable Before Debugging
- Related lesson: Read a Dense SQL Query Before Changing It