FE7: The modern frontend toolkit

Lesson 4 of 5 ยท reading 15โ€“25 minutes; practice and project time is on the module page

Linting, formatting and code checks

๐ŸŽฏYou'll be able to

Set up linting and formatting so code checks run the same for everyone.

๐Ÿ The everyday picture

A newspaper's sub-editor checks spelling, house style and facts before print, so the writer can focus on the story. Linters and formatters are automatic sub-editors for code.

๐Ÿ“˜What it really is

๐Ÿ“A worked example

Adding the react-hooks and jsx-a11y rules to Kirana's codebase:

Rule Findings Example
react-hooks/exhaustive-deps 11 Store picker effect missing storeId in its dependencies
jsx-a11y/alt-text 7 Category images without alt
jsx-a11y/click-events-have-key-events 4 Clickable divs
@typescript-eslint/no-explicit-any 19 API helpers

The missing dependency explained a long-standing bug where stock sometimes showed for the previous store.

๐ŸŒWhere it's used

๐Ÿ“Case scenario

Every pull request in a team has dozens of comments about spacing and quote style, and arguments slow merges. Adding Prettier with a shared config, formatting the codebase once in a single commit, and checking formatting in CI ends the debate. Reviews get shorter and more useful.

๐Ÿ–ฑ๏ธTry it

Add Prettier, ESLint with the react-hooks and jsx-a11y rules, and a type check to your Kirana project. Set up a pre-commit hook for changed files, then fix everything the tools report and note the most surprising finding.

โš ๏ธCommon mistakes

๐Ÿ› ๏ธFor your project

Add a lint check to your Project 2 work and include its result in your evidence.

โœ…Quick check

What's the difference between a formatter and a linter?

Show the answer

A formatter fixes how code looks; a linter finds likely bugs and risky patterns.

How should you add strict lint rules to a large old codebase?

Show the answer

Gradually, fixing files as they're touched, rather than in one huge change.

โ† PreviousTailwind CSS and design tokens
ProLearners Assist