eslint-plugin-prettier

raw JSON →
5.5.5 verified Sat Apr 25 auth: no javascript

Runs Prettier as an ESLint rule, reporting formatting differences as individual lint issues. Current stable version is v5.5.5, released Jan 2025. Requires ESLint >=8, Prettier >=3, and eslint-config-prettier >=7. Actively maintained with monthly releases. Ships TypeScript types and supports flat config (eslint.config.js) and legacy .eslintrc. Integrates with eslint-config-prettier to disable conflicting rules. Notable features: supports non-JS languages (CSS, JSON) via @eslint/css and @eslint/json plugins, Svelte support, and configurable options like 'usePrettierrc' and 'fileInfoOptions'. Faster than prettier-eslint as it avoids double parsing.

error Error: Failed to load plugin 'prettier' declared in 'plugins': Cannot find module 'eslint-plugin-prettier'
cause Plugin not installed or not in node_modules.
fix
Run 'npm install --save-dev eslint-plugin-prettier'.
error TypeError: Cannot read properties of undefined (reading 'message')
cause Bug in synckit <=0.11.6 used by prettier-linter-helpers.
fix
Upgrade to eslint-plugin-prettier v5.4.1+ which bumps synckit to v0.11.7.
error Parsing error: Unexpected token }
cause ESLint parser is not configured for the file type (e.g., TypeScript or JSX).
fix
Install and configure @typescript-eslint/parser or eslint-plugin-react.
error ESLint couldn't determine the plugin for rule 'prettier/prettier'
cause Plugin not listed in 'plugins' array in flat config.
fix
Add 'prettier: eslintPluginPrettier' to the plugins object in your flat config.
breaking Requires Prettier >=3.0.0 and ESLint >=8.0.0 as peer dependencies since v5.0.0.
fix Upgrade Prettier to v3+ and ESLint to v8+.
breaking v5.x drops support for Node.js <14.18 and uses ESM exports internally; some bundlers may need configuration.
fix Use Node 14.18+ or 16+; for CJS projects, use dynamic import or upgrade to Node 22+ with require(esm) support.
deprecated The 'prettier/prettier' rule options object now uses 'prettierOptions' instead of 'options' in v5.5.0+.
fix Rename the 'options' property to 'prettierOptions' in rule configuration.
gotcha Incompatible with eslint-plugin-prettier's own 'arrow-body-style' and 'prefer-arrow-callback' rules; must disable them manually or use the recommended config.
fix Add 'arrow-body-style': 'off' and 'prefer-arrow-callback': 'off' in your ESLint rules.
gotcha When using flat config, the recommended config is exported as 'eslint-plugin-prettier/recommended' (a single config object), not 'plugin.configs.recommended'.
fix Use 'import recommended from "eslint-plugin-prettier/recommended"' and spread it in your config array.
npm install eslint-plugin-prettier
yarn add eslint-plugin-prettier
pnpm add eslint-plugin-prettier

Flat config setup with eslint-plugin-prettier and eslint-config-prettier to automatically fix formatting.

// eslint.config.js
import eslintPluginPrettier from 'eslint-plugin-prettier';
import eslintConfigPrettier from 'eslint-config-prettier';

export default [
  {
    plugins: {
      prettier: eslintPluginPrettier,
    },
    rules: {
      'prettier/prettier': 'error',
      'arrow-body-style': 'off',
      'prefer-arrow-callback': 'off',
    },
  },
  eslintConfigPrettier,
];

// Then run: npx eslint .
// This will check all files with Prettier formatting.