Letting a Formatter Decide the Style

Maya and Theo now share release-note/release-note.js for Fernleaf Bakery’s end-of-day note. They agree on the names, but Theo prefers single quotes and four-space indents. How should they settle those choices? In Python, PEP 8 and Black offer style guidance. JavaScript leaves the style to the project. You’ll distinguish the tools that handle style from the syntax check you can run before tomorrow’s handover.

Let the Formatter Choose

A formatter reprints code with a consistent layout. Prettier plays Black’s role in JavaScript. Unlike Black, it has options for quotes and semicolons. The team chooses those once, and everyone follows the project’s configuration.

For the release note, use two-space indentation, double quotes, and semicolons, matching this course’s style. Another project may choose single quotes instead. JavaScript’s braces define blocks, so indentation can follow the formatter’s choice instead of carrying Python’s structural role.

Formatting preserves the program’s meaning. It won’t repair a condition or move a statement into the block you intended. ESLint is a linter that checks for likely mistakes, much like Ruff. Ruff also formats, while JavaScript projects commonly pair ESLint with Prettier. Installation can wait until you work with packages.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.