
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
prettier-detect
Advanced tools
A CLI tool to figure out the least disruptive Prettier config to add to an existing project.
A CLI tool to figure out the least disruptive Prettier config to add to an existing project.
[!WARNING]
This project was just a quick exploration of an idea. It's shared as a curiosity and won't be actively maintained or improved.
Sometimes you wind up in an unfamiliar repository, without a formatter in sight and where every ⌘-s triggers auto formatting, seeding noise and despair in the next commit's diff.
You want to throw in some kind of formatter to take the edge off this, but you don't want to spend time reverse-engineering the stylistic proclivities of the author into a do-no-harm .prettierrc file.
The prettier-detect CLI tool helps out here, by fuzzing through Prettier config combinations to find the configuration that minimizes the size of the post-format diff.
Useful for random forks, useful for projects that are late to adopt formatters.
Prettier detect requires Node 18+. The exported APIs are ESM-only and share the Node 18+ requirement. You'll also need a git binary somewhere in your path.
Invoke directly:
npx prettier-detect
Or, install globally for access across your system:
npm install --global prettier-detect
Just run prettier-detect in the repo in question, redirecting the output if you'd like to save it straight to a config file:
prettier-detect ./ > .prettierrc.json
It can take a while to run on large repos. It's trying a lot of combinations.
Default configuration values are remove by default.
prettier-detectGet the least disruptive Prettier config to add to an existing project.
Usage:
prettier-detect <directory>
| Positional Argument | Description | Type |
|---|---|---|
directory | Directory to evaluate. | string |
| Option | Description | Type | Default |
|---|---|---|---|
--strip | Strip any discovered configuration values that match Prettier's defaults. | boolean | true |
--strategy | How to search the possibility space. "fuzz" brute-forces config permutations, "popular" tests the most common Prettier configs found in popular GitHub repositories. | "popular" "fuzz" | "popular" |
--verbose | Enable verbose logging. All verbose logs and prefixed with their log level and are printed to stderr for ease of redirection. | boolean | false |
--help-h | Show help | boolean | |
--version-v | Show version number | boolean |
A single function is exported, which works just like the CLI tool, except it returns a Prettier configuration options object instead of.
export async function detectConfig(
path: string,
strip = true,
verbose = false,
): Promise<PrettierOptions>
MIT © Eric Mika
FAQs
A CLI tool to figure out the least disruptive Prettier config to add to an existing project.
We found that prettier-detect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.