Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 40 of 56 · Typescript

Linting & Formatting – ESLint, Prettier, and `eslint-plugin-typescript`

Duration: 20 minutes

Install ESLint & Prettier

npm i -D eslint prettier eslint-config-prettier eslint-plugin-prettier @typescript-eslint/parser @typescript-eslint/eslint-plugin

Init ESLint

npx eslint --init

Select TypeScript, React (if applicable), and Prettier integration.

Sample .eslintrc.json

{
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint", "prettier"],
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:prettier/recommended"
  ],
  "rules": {
    "@typescript-eslint/no-unused-vars": "error",
    "prettier/prettier": "error"
  }
}

Prettier config (.prettierrc)

{ "singleQuote": true, "trailingComma": "all" }

Add scripts to package.json:

"scripts": {
  "lint": "eslint 'src/**/*.{ts,tsx}'",
  "format": "prettier --write 'src/**/*.{ts,tsx,js,jsx,json,md}'"
}

Run npm run lint and npm run format.

Info

Enable git hooks (husky) to auto‑run lint/format on commit.

Previous: Mocking & Spying in JestNext: Build Tools – `tsc` vs. Babel vs. SWC