package
CLI for prettier-eslint
npm install prettier-eslint-cliGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Latest published Jun 19, 2026
latest
alpha
CLI for prettier-eslint
You have a bunch of files that you want to format using prettier-eslint.
But prettier-eslint can only operate on strings.
This is a CLI that allows you to use
prettier-eslint on one or multiple files. prettier-eslint-cli forwards on the filePath
and other relevant options to prettier-eslint which identifies the applicable ESLint
config for each file and uses that to determine the options for prettier and eslint --fix.
This module is distributed via npm which is bundled with node and should
be installed (with yarn) as one of your project's devDependencies:
yarn add --dev prettier-eslint-cliIf you're still using the
npmclient:npm install --save-dev prettier-eslint-cli
Typically you'll use this in your npm scripts (or package scripts):
{
"scripts": {
"format": "prettier-eslint \"src/**/*.js\""
}
}This will format all .js files in the src directory. The argument you pass to the CLI
is a glob and you can pass as many as you wish. You can also pass options.
Vim users can add the following to their .vimrc:
autocmd FileType javascript set formatprg=prettier-eslint\ --stdinThis makes prettier-eslint-cli power the gq command for automatic formatting without any plugins. You can also add the following to your .vimrc to run prettier-eslint-cli when .js files are saved:
autocmd BufWritePre *.js :normal gggqGprettier-eslint --help
Usage: prettier-eslint <globs>... [--option-1 option-1-value --option-2]
Prefix an option with "no-" to set it to false, such as --no-semi to
disable semicolons and --no-eslint-ignore to disable default ignores.
Options:
-h, --help Show help [boolean]
--version Show version number [boolean]
--write Edit the file in-place (beware!)
[boolean] [default: false]
--stdin Read input via stdin [boolean] [default: false]
--stdin-filepath Path to the file to pretend that stdin comes from.
--eslint-ignore Only format matching files when they are not ignored
by ESLint config or default ignores. (can use
--no-eslint-ignore to disable this) [boolean] [default: true]
--prettier-ignore Only format matching files even if they are not
ignored by .prettierignore. (can use
--no-prettier-ignore to disable this)
[boolean] [default: true]
--list-different Print filenames of files that are different from
Prettier + Eslint formatting.
[boolean] [default: false]
--include-dot-files Include files that start with a dot in the search.
[boolean] [default: false]
Any number of globs you wish to use to match the files you wish to format. ESLint's default ignores are applied, so node_modules/ and .git/ entries are skipped unless you explicitly unignore them with --ignore negation patterns such as --ignore '!**/node_modules/'.
By default prettier-eslint will simply log the formatted version to the terminal. If you want to overwrite the file
itself (a common use-case) then add --write. You should quote your globs, otherwise your terminal will expand the glob before it gets to prettier-eslint (which can have unexpected results):
{
"scripts": {
"format": "prettier-eslint --write \"src/**/*.js\""
}
}NOTE: It is recommended that you keep your files under source control and committed before running
prettier-eslint --writeas it will overwrite your files!
Instead of printing the formatted version of the files to the terminal, prettier-eslint will log the name of the files that are different from the expected formatting. This can be usefull when using prettier-eslint in a version control system hook to inform the committer which files need to be formatted.
Accept input via stdin. For example:
echo "var foo = 'bar'" | prettier-eslint --stdin
# results in: "var foo = 'bar';" (depending on your eslint config)Forwarded as the eslintPath option to prettier-eslint
Resolve eslint config file, parse and forward config object as the eslintConfig option to
prettier-eslint
Forwarded as the prettierPath option to prettier-eslint
Forwarded as logLevel option to prettier-eslint
Disables ESLint config and default ignores for files resolved from the glob. By
default, prettier-eslint-cli excludes files matched by ESLint config ignores,
plus default ignores like node_modules/ and .git/. Use ESLint-style --ignore
negation patterns such as --ignore '!**/node_modules/' to unignore specific
paths without disabling all ESLint ignore handling.
Note: You can also set the
LOG_LEVELenvironment variable to control logging inprettier-eslint
By default, prettier-eslint-cli will run prettier first, then eslint --fix. This is great if
you want to use prettier, but override some of the styles you don't like using eslint --fix.
An alternative approach is to use different tools for different concerns. If you provide the
argument --prettier-last, it will run eslint --fix first, then prettier. This allows you to
use eslint to look for bugs and/or bad practices, and use prettier to enforce code style.
prettier optionsprettier-eslint-cli also supports the same command line options as prettier.
For example: prettier-eslint --trailing-comma es5
Refer to the prettier-eslint docs for documentation on these options
Any linter that support ESLint CLIEngine interface can be integrate with prettier-eslint
prettier-eslint-cliThanks goes to these people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT
kentcdodds
me@kentcdodds.com
Adam Harris 💻 📖 👀 |
Eric McCormick 👀 |
Joel Sequeira 📖 |
Frank Taillandier |
Adam Stankiewicz 💻 |
Stephen John Sorensen 💻 |
Gandem 💻 ⚠️ | Matteo Ronchi 🐛 💻 | Benoît Zugmeyer 💻 ⚠️ | Charlike Mike Reagent 💻 ⚠️ | Dion Dirza 🐛 | mrm007 🐛 💻 | Jack Franklin 💻 |
Ryan Zimmerman 📖 | Paolo Moretti 🐛 💻 ⚠️ | bySabi Files 📖 🔧 | Pavel Pertsev 💻 ⚠️ | Josh English ⚠️ 🐛 💻 🔌 | Spenser Isdahl 💻 📖 ⚠️ | Björn Dalfors 🚇 |
Steven Scaffidi 📖 | Daniel Wilhelmsen 💻 🚧 | Glen Whitney 🚧 | Rebecca Vest 💻 | JounQin 💬 💻 🎨 📖 🤔 🚇 🚧 | dorser 💻 🚧 | さくら 💻 |
outslept 💻 |
Estimated unpacked size across 61 packages.
10.2 MB+
Includes dependencies.
^6.0.0
6.0.2
^0.16.8
0.17.0
^5.0.0
6.0.0
npm:prettier-eslint@^17.1.0
^0.23.5
0.23.6
1.0.0