eslint-plugin-prettier
ESLint plugin for prettier formatting
An ESLint plugin that runs Prettier as a lint rule, so formatting problems show up alongside code-quality issues and can be auto-fixed with one command.
What This Does
This plugin bridges two popular code tools: ESLint (which checks for code problems) and Prettier (which automatically formats code to look consistent). Instead of running Prettier separately, this plugin lets ESLint report formatting issues directly, so you see all your code problems in one place. When Prettier would change your code's formatting, ESLint will flag it as an error, and you can fix it automatically with the --fix command.
How It Works
ESLint normally runs rules that check for things like unused variables or suspicious patterns. This plugin adds a new rule that essentially says "check if this code matches Prettier's formatting style." When ESLint runs, it compares your actual code against what Prettier would produce. If there's a difference—like a missing comma or an extra semicolon—it reports it the same way it would report any other linting problem. You can then let ESLint auto-fix the issue, and your code gets reformatted to match Prettier's standards.
Who Uses This and Why
This is useful for teams that want a single, unified linting workflow. Instead of running both ESLint and Prettier as separate tools, developers can run just ESLint once and get feedback on both code quality and formatting. It's especially helpful in editor integrations, where you might see real-time feedback on formatting issues as you type. The README notes that it works best when you disable other ESLint formatting rules, so Prettier becomes the single source of truth for how code should look.
A Key Tradeoff
The README recommends configuring Prettier through a .prettierrc file rather than through ESLint's config file. This is because code editors that support Prettier directly won't read ESLint settings, which could cause your editor to format code one way and ESLint to expect it formatted differently. By keeping Prettier's settings in its own config file, you ensure consistency everywhere.
Where it fits
- Get formatting issues reported alongside other lint errors in one workflow.
- Auto-fix formatting problems by running ESLint's --fix command.
- Show real-time formatting feedback in editors with ESLint integration.
- Make Prettier the single source of truth for a team's code style.