Lesson 1 · Unit 03
Linters and formatters
Formatter, linter, type checker: what each is configured to do, and where each one runs
What you practise
- What each one catches, reading their output, a shared config, hooks that run before a commit
Try a question from this lesson
Pick one
A review of a 12-line change has drawn 30 comments, and 26 of them are about quote style and where the braces go. What should the team change?
Correct answer
Let a tool rewrite the layout on every save
Why
A style guide still has to be read, remembered and enforced by people. A formatter makes the layout a non-decision: nobody chooses it, so nobody reviews it, and the four comments about behaviour get the attention.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Three tools, three jobs
A formatter rewrites layout: spacing, quotes, line breaks. It never changes what the code means.
A linter reads the code without running it and flags suspicious patterns, each one a named rule.
A type checker proves that values fit where they are used.
Layout, patterns, proof. Each catches what the others cannot.
Concept
Config lives in the repository
Each tool reads its settings from a file in the project. This one tells the Prettier formatter: semicolons, single quotes, wrap at 80 columns.
Because the file is committed, every editor and every CI machine formats the same way. Style is argued once, in the review of this file.
{
"semi": true,
"singleQuote": true,
"printWidth": 80
}10 more exercises in the app
- 1× match the pairs
- 3× type the answer
- 3× multiple choice
- 1× true or false
- 1× fill the blanks
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.