# Linting and Formatting

> Catch bugs automatically with ESLint and end style debates with Prettier, wired into your editor and commits. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/frontend/linting-formatting
Last updated: 2026-11-28

Catch bugs automatically with ESLint and end style debates with Prettier, wired into your editor and commits.

Beginner · about 2 hours · difficulty 1/5

Learn first: [Package Managers](https://www.internhack.in/roadmaps/tracks/frontend/package-managers)

Linters and formatters are cheap, automatic code reviewers. Teams adopt them so humans can review logic instead of arguing about semicolons.

### ESLint: finds problems

ESLint statically analyses code and reports likely bugs: unused variables, missing `await`, unreachable code, misuse of React hooks (`eslint-plugin-react-hooks` is essential), accessibility issues in JSX (`eslint-plugin-jsx-a11y`). Modern ESLint uses a **flat config** file (`eslint.config.js`) and `typescript-eslint` for type-aware rules. Many rules can auto-fix.

### Prettier: formats code

Prettier reformats code to one consistent style (quotes, wrapping, trailing commas) with very few options on purpose. Run it on save in your editor. Let Prettier own formatting and ESLint own correctness; `eslint-config-prettier` turns off ESLint rules that would conflict. Biome is a newer, faster tool that combines both roles.

### Automate it

- Editor integration: format on save, show lint errors inline.
- Pre-commit hooks with **husky** and **lint-staged** run checks on changed files only.
- Run `lint` and `typecheck` in CI so rules are enforced for everyone.
- An `.editorconfig` keeps indentation consistent across editors.

### Pitfall

Do not enable hundreds of stylistic rules nobody agreed on. Start with recommended presets, add rules when a real bug slips through, and treat warnings you ignore as noise to either fix or delete.

Move on when your projects lint and format automatically on save and in CI, with zero warnings.

## Key concepts

- **ESLint flat config**
- **Recommended rule sets**
- **Prettier**
- **eslint-config-prettier**
- **Editor format on save**
- **husky and lint-staged**
- **Biome**: All-in-one alternative

## Mini project

Add ESLint and Prettier to your Vite project with a pre-commit hook, then deliberately commit an unused variable and a misformatted file to confirm they are blocked or fixed.

## Check yourself

Why should ESLint and Prettier have separate responsibilities, and what goes wrong if both enforce formatting?

## Free resources

- [ESLint: Getting Started](https://eslint.org/docs/latest/use/getting-started) (ESLint)
- [Prettier Docs](https://prettier.io/docs/) (Prettier)

Previous: [Build Tools and Bundlers](https://www.internhack.in/roadmaps/tracks/frontend/build-tools) · Next: [Tailwind CSS](https://www.internhack.in/roadmaps/tracks/frontend/tailwind)

## More in Everyday Workflow and Tooling

- [Git and GitHub](https://www.internhack.in/roadmaps/tracks/frontend/git)
- [JavaScript Modules](https://www.internhack.in/roadmaps/tracks/frontend/js-modules)
- [Package Managers](https://www.internhack.in/roadmaps/tracks/frontend/package-managers)
- [Build Tools and Bundlers](https://www.internhack.in/roadmaps/tracks/frontend/build-tools)
- [Linting and Formatting](https://www.internhack.in/roadmaps/tracks/frontend/linting-formatting)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Frontend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/frontend)
