Registry / testing / prettier-eslint-cli

prettier-eslint-cli

JSON →
library8.0.1jsnpmunverified

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-cli
INSTALL
IMPORT
SIG · PRETTIER-ESLINT-CL
P
prettier-eslint-cli
testingjavascriptv8.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

prettier-eslint-cli (binary)
npx prettier-eslint-cli --write 'src/**/*.js'
import { format } from 'prettier-eslint-cli'
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.
Configuration options
npx prettier-eslint-cli --print-width 80 --single-quote --write 'src/**/*.ts'
const config = { printWidth: 80 }; prettierEslintCli.format(code, config);
CLI options are passed as command-line flags. Consult the official documentation for a complete list of available flags and their usage.
Glob patterns
npx prettier-eslint-cli 'src/**/*.{js,ts}' 'test/**/*.test.js'
npx prettier-eslint-cli src/index.js,src/utils.js
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.

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.

#!/usr/bin/env bash # Create a directory and some dummy JavaScript and TypeScript files mkdir -p src echo "const foo = \"bar\"; function add(a,b){return a + b;}" > src/file1.js echo "let x = 10; const myObject = { key: 'value', other: 123 };" > src/file2.ts # Install the necessary peer dependencies (Prettier, ESLint, prettier-eslint) # This ensures that prettier-eslint-cli has the underlying tools it needs. npm install --save-dev prettier eslint prettier-eslint # Optionally, create minimal configuration files for prettier and eslint # .prettierrc.json echo '{"singleQuote": true, "semi": true, "printWidth": 80}' > .prettierrc.json # .eslintrc.js (using recommended configs for demonstration) echo 'module.exports = { extends: ["eslint:recommended", "prettier"] };' > .eslintrc.js # Run prettier-eslint-cli to format and fix the files in place npx prettier-eslint-cli --write 'src/**/*.js' 'src/**/*.ts' # Output the content of the formatted files to see the changes echo "\n--- Formatted src/file1.js ---" cat src/file1.js echo "\n--- Formatted src/file2.ts ---" cat src/file2.ts # Expected output for src/file1.js (example, exact depends on config): # const foo = 'bar'; # function add(a, b) { # return a + b; # }
prettier-eslint --version
Debug
Known issues
breakingVersion 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.
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.
affects: >=9.0.0-alpha.0
breakingVersion 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.
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.
affects: >=8.0.0
breakingVersion 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.
fix
After upgrading to v7, explicitly ensure `prettier-eslint` is installed as a direct or peer dependency in your project: `npm install prettier-eslint`.
affects: >=7.0.0 <8.0.0
gotchaConflicting 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.
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.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-eslint'
The `prettier-eslint` package, which provides the core formatting and fixing logic, is a required peer dependency but is not installed in your project.
fix
Install `prettier-eslint` explicitly in your project: `npm install prettier-eslint` or `yarn add prettier-eslint`.
Error: Minimum Node.js version not met. Expected >=16.10.0 but got vX.Y.Z
The installed Node.js version is older than the minimum requirement for `prettier-eslint-cli` v8.0.0 and above.
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`).
Formatting error: Some files could not be formatted. This may indicate an issue with your Prettier or ESLint configuration.
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.
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.
Command not found: prettier-eslint-cli
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.
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`.
Upgrade
Version history
8.0.1latest on npm
Audit
Dependencies
prettier-eslintrequiredProvides 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.
Agent activity
4 hits · last 30 days
node
4
Resources