prettier-plugin-eslint
raw JSON → 1.0.2 verified Sat Apr 25 auth: no javascript
Automatically integrates ESLint's auto-fix functionality into Prettier formatting, so that running Prettier also applies ESLint --fix. Version 1.0.2 is the current stable release; the plugin runs ESLint on .js files before Prettier formatting. Compared to alternatives like prettier-eslint, this is a Prettier plugin (not a separate CLI) and requires no extra configuration beyond installation. It assumes ESLint configuration is in an .eslintrc file (package.json support planned).
Common errors
error Error: Cannot find module 'prettier-plugin-eslint' ↓
cause Plugin not installed or not found in node_modules.
fix
Run 'npm install --save-dev prettier-plugin-eslint'.
error Couldn't resolve plugin "prettier-plugin-eslint" ↓
cause Plugin name not specified correctly in .prettierrc.
fix
Use full package name: { "plugins": ["prettier-plugin-eslint"] }
error ESLint configuration not found. .eslintrc file is required. ↓
cause Missing ESLint config file; package.json eslintConfig not supported.
fix
Create an .eslintrc file (e.g., .eslintrc.json) in project root.
error Cannot read property 'config' of undefined ↓
cause Plugin runs before ESLint is initialized due to missing dependencies.
fix
Ensure both 'prettier' and 'eslint' are installed as devDependencies.
Warnings
gotcha Plugin only processes .js files; other file types (ts, json, css) are not linted. ↓
fix Use separate plugins (e.g., prettier-plugin-tslint) for non-JS files.
gotcha The plugin runs ESLint before Prettier; formatting from ESLint may conflict with Prettier styles. ↓
fix Ensure ESLint rules are compatible with Prettier output; use eslint-config-prettier to disable conflicting rules.
gotcha ESLint configuration must be in .eslintrc file (JSON, YAML, or JS); package.json 'eslintConfig' key is not supported. ↓
fix Move ESLint config to an .eslintrc file or wait for package.json support.
gotcha The plugin does not support ESLint's --fix-to-stdout or other CLI flags. ↓
fix Run ESLint directly if custom fix behavior is needed.
breaking Version 1.0.0 required Prettier >= 2.0. Older Prettier versions are incompatible. ↓
fix Upgrade Prettier to version 2.0 or later.
Install
npm install prettier-plugin-eslint yarn add prettier-plugin-eslint pnpm add prettier-plugin-eslint Imports
- plugin wrong
import plugin from 'prettier-plugin-eslint'correct// No import needed; install and it auto-registers with Prettier. - default wrong
require('prettier-plugin-eslint')correct// In .prettierrc: { "plugins": ["prettier-plugin-eslint"] } - use with Prettier API wrong
const plugin = require('prettier-plugin-eslint');correctconst prettier = require('prettier'); await prettier.format(code, { parser: 'babel', plugins: ['prettier-plugin-eslint'] });
Quickstart
npm install --save-dev prettier prettier-plugin-eslint eslint
echo '{"plugins": ["prettier-plugin-eslint"]}' > .prettierrc
echo '{"rules": {"semi": ["error", "never"]}}' > .eslintrc.json
# Create a test file
echo 'const x = 1;' > test.js
# Run Prettier
npx prettier --write test.js
# Verify that semicolon is removed (ESLint --fix applied)
cat test.js # should output: const x = 1