prettier-eslint-cli is a command-line interface (CLI) tool designed to streamline code formatting by integrating Prettier with ESLint. It first formats code using Prettier, then passes the output to ESLint for auto-fixing any remaining linting issues according to your ESLint configuration. This approach helps resolve potential conflicts between Prettier's strict formatting and ESLint's stylistic rules. The current stable version is 8.0.1, though alpha versions for v9 are actively being released, indicating ongoing development, including support for ESLint v9's new flat config system. Key differentiators include its single-command workflow for combined formatting and linting, and its intelligent handling of tool conflicts by prioritizing Prettier's output before ESLint's fixes. It primarily targets JavaScript and TypeScript projects that utilize both tools for code quality.
npm install prettier-eslint-cliVerified import paths — ran on the pinned version, not inferred.
This script demonstrates how to set up `prettier-eslint-cli` in a project, including installing its peer dependencies and creating minimal configuration files. It then uses `npx prettier-eslint-cli` to format and fix both JavaScript and TypeScript files, showing the before-and-after content.
If migrating to ESLint v9, update your project's ESLint configuration to the flat config format. If staying on legacy ESLint configurations, use `prettier-eslint-cli` v8 or earlier.
Upgrade your Node.js environment to version 16.10.0 or higher. Tools like `nvm` or `volta` can assist in managing multiple Node.js versions.
After upgrading to v7, explicitly ensure `prettier-eslint` is installed as a direct or peer dependency in your project: `npm install prettier-eslint`.
Carefully audit your `.prettierrc` and `.eslintrc` files. Use `eslint-config-prettier` to disable all ESLint rules that conflict with Prettier, allowing Prettier to be the sole source of truth for formatting.
Install `prettier-eslint` explicitly in your project: `npm install prettier-eslint` or `yarn add prettier-eslint`.
Upgrade your Node.js runtime to version 16.10.0 or newer. You can use tools like `nvm` (`nvm install 18 && nvm use 18`) or `volta` (`volta install node@18`).
First, run Prettier and ESLint separately (`prettier --check <files>` and `eslint --fix <files>`) to pinpoint which tool is failing. Then, review your `.prettierrc` and `.eslintrc` files for conflicting rules or syntax errors in the processed code. Ensure `eslint-config-prettier` is properly configured.
Ensure the package is installed in your project (`npm install prettier-eslint-cli --save-dev`) and always run it using `npx prettier-eslint-cli`. If you want to use it globally, install it with `npm install -g prettier-eslint-cli`.