{"id":17048,"library":"prettier-eslint-cli","title":"Prettier ESLint CLI","description":"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.","status":"active","version":"8.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/prettier/prettier-eslint-cli","tags":["javascript"],"install":[{"cmd":"npm install prettier-eslint-cli","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-eslint-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-eslint-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the core logic for combining Prettier formatting and ESLint auto-fixing. While technically a peer dependency, it is essential for the CLI's core functionality.","package":"prettier-eslint","optional":false}],"imports":[{"note":"This package is a command-line interface; it does not export a direct JavaScript API for programmatic use. For programmatic interaction, refer to the `prettier-eslint` package directly.","wrong":"import { format } from 'prettier-eslint-cli'","symbol":"prettier-eslint-cli (binary)","correct":"npx prettier-eslint-cli --write 'src/**/*.js'"},{"note":"CLI options are passed as command-line flags. Consult the official documentation for a complete list of available flags and their usage.","wrong":"const config = { printWidth: 80 }; prettierEslintCli.format(code, config);","symbol":"Configuration options","correct":"npx prettier-eslint-cli --print-width 80 --single-quote --write 'src/**/*.ts'"},{"note":"Multiple files and glob patterns should be space-separated arguments. It is crucial to quote glob patterns to ensure they are interpreted correctly by your shell instead of being expanded prematurely.","wrong":"npx prettier-eslint-cli src/index.js,src/utils.js","symbol":"Glob patterns","correct":"npx prettier-eslint-cli 'src/**/*.{js,ts}' 'test/**/*.test.js'"}],"quickstart":{"code":"#!/usr/bin/env bash\n\n# Create a directory and some dummy JavaScript and TypeScript files\nmkdir -p src\necho \"const foo = \\\"bar\\\"; function add(a,b){return a + b;}\" > src/file1.js\necho \"let x = 10; const myObject = { key: 'value', other: 123 };\" > src/file2.ts\n\n# Install the necessary peer dependencies (Prettier, ESLint, prettier-eslint)\n# This ensures that prettier-eslint-cli has the underlying tools it needs.\nnpm install --save-dev prettier eslint prettier-eslint\n\n# Optionally, create minimal configuration files for prettier and eslint\n# .prettierrc.json\necho '{\"singleQuote\": true, \"semi\": true, \"printWidth\": 80}' > .prettierrc.json\n# .eslintrc.js (using recommended configs for demonstration)\necho 'module.exports = { extends: [\"eslint:recommended\", \"prettier\"] };' > .eslintrc.js\n\n# Run prettier-eslint-cli to format and fix the files in place\nnpx prettier-eslint-cli --write 'src/**/*.js' 'src/**/*.ts'\n\n# Output the content of the formatted files to see the changes\necho \"\\n--- Formatted src/file1.js ---\"\ncat src/file1.js\n\necho \"\\n--- Formatted src/file2.ts ---\"\ncat src/file2.ts\n\n# Expected output for src/file1.js (example, exact depends on config):\n# const foo = 'bar';\n# function add(a, b) {\n#   return a + b;\n# }","lang":"typescript","description":"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."},"warnings":[{"fix":"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.","message":"Version 9.0.0-alpha.0 introduces explicit support for ESLint v9's new flat configuration system (`eslint.config.js`). Projects still relying on the legacy `.eslintrc` configuration format may encounter compatibility issues and should either update their ESLint setup or remain on `prettier-eslint-cli` v8.","severity":"breaking","affected_versions":">=9.0.0-alpha.0"},{"fix":"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.","message":"Version 8.0.0 dropped support for Node.js versions older than 16.10.0. Attempting to run `prettier-eslint-cli` v8 or newer on unsupported Node.js versions will result in runtime errors.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"After upgrading to v7, explicitly ensure `prettier-eslint` is installed as a direct or peer dependency in your project: `npm install prettier-eslint`.","message":"Version 7.0.0 included significant dependency bumps and internal refactorings. While the CLI was updated to better handle the `prettier-eslint` peer dependency, users might still need to ensure `prettier-eslint` is explicitly installed to avoid functionality issues.","severity":"breaking","affected_versions":">=7.0.0 <8.0.0"},{"fix":"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.","message":"Conflicting Prettier and ESLint configurations are a common source of issues, potentially leading to inconsistent formatting, unexpected errors, or even infinite formatting loops if rules continuously revert each other's changes.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Install `prettier-eslint` explicitly in your project: `npm install prettier-eslint` or `yarn add prettier-eslint`.","cause":"The `prettier-eslint` package, which provides the core formatting and fixing logic, is a required peer dependency but is not installed in your project.","error":"Error: Cannot find module 'prettier-eslint'"},{"fix":"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`).","cause":"The installed Node.js version is older than the minimum requirement for `prettier-eslint-cli` v8.0.0 and above.","error":"Error: Minimum Node.js version not met. Expected >=16.10.0 but got vX.Y.Z"},{"fix":"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.","cause":"This often occurs when there's an unresolvable conflict between Prettier's formatting and ESLint's auto-fix rules, or if there are syntax errors in the input files that prevent successful parsing by either tool.","error":"Formatting error: Some files could not be formatted. This may indicate an issue with your Prettier or ESLint configuration."},{"fix":"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`.","cause":"The `prettier-eslint-cli` binary is not located in your system's PATH, or the package is not installed globally, or it's not accessible via `npx` from your current directory.","error":"Command not found: prettier-eslint-cli"}],"ecosystem":"npm","meta_description":null}