JS Guide
HomeQuestionsSearchResources
Search

Built for developers preparing for JavaScript, React & TypeScript interviews.

ResourcesQuestionsSupport
HomeQuestionsSearchProgress
HomeQuestionstooling
PrevNext
tooling
junior
formatting

What is Prettier and how does it differ from ESLint?

prettier
formatting
code-style
eslint
Quick Answer

Prettier is an opinionated code formatter that automatically formats code for consistent style. Unlike ESLint (which checks code quality and some style), Prettier only handles formatting. Use both together: ESLint for bugs, Prettier for formatting.

Detailed Explanation

Prettier vs ESLint:

ESLint:

  • Code quality rules
  • Catches bugs/errors
  • Some formatting rules
  • Configurable rules

Prettier:

  • Only formatting
  • Opinionated (few options)
  • Consistent output
  • Fast auto-format

Using Together:

  1. ESLint for code quality
  2. Prettier for formatting
  3. eslint-config-prettier to avoid conflicts

Prettier Philosophy:

  • Minimal config options
  • End style debates
  • Format on save

Code Examples

Prettier configuration
// .prettierrc
{
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "es5",
  "printWidth": 80,
  "bracketSpacing": true,
  "arrowParens": "always"
}

// .prettierignore
node_modules/
dist/
build/
coverage/
*.min.js

Resources

Prettier Documentation

docs

Related Questions

What is ESLint and why should you use it?

junior
linting
Previous
What is ESLint and why should you use it?
Next
What is Vite and why is it faster than traditional bundlers?