Course contentsShow
← JavaScript
Lesson 2580 of 2,72352. Linting and FormattingFree lesson

Integrating Prettier with ESLint

Use eslint-config-prettier to disable conflicting ESLint style rules that Prettier handles.

Integrating Prettier with ESLint

You'll learn how to prevent ESLint and Prettier from fighting over code style by using eslint-config-prettier.

The Problem: Two Formatters, One Codebase

You've configured ESLint to catch bugs and enforce coding standards. You've also set up Prettier to automatically format your code. But here's the issue: both tools have opinions about code style.

ESLint has rules like indent, quotes, max-len, and semi that dictate formatting. Prettier also formats indentation, quotes, line length, and semicolons. When both run on the same file, they can contradict each other—ESLint might complain about something Prettier just formatted, or vice versa.

It's like having two editors reviewing your manuscript with conflicting style guides. One insists on Oxford commas while the other forbids them.

The Solution: eslint-config-prettier

The eslint-config-prettier package solves this by disabling all ESLint rules that conflict with Prettier's formatting. It doesn't change how Prettier works—it simply tells ESLint to step back and let Prettier handle style.

After installing it (npm install --save-dev eslint-config-prettier), you add it to your ESLint configuration's extends array as the last item:

// .eslintrc.js or eslint.config.js
module.exports = {
  extends: [
    'eslint:recommended',
    'prettier' // Must come last to override other configs
  ],
  // ... other config
};

By placing 'prettier' last, you ensure it turns off conflicting rules from any previous configs.

Now ESLint focuses on code quality (catching bugs, unused variables, etc.) while Prettier handles all formatting (indentation, line breaks, quotes). They work in harmony instead of competing.

Key Takeaway: Use eslint-config-prettier as the last item in your ESLint extends array to disable style rules that Prettier already handles, letting each tool do what it does best without conflicts.