npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prettier-detect

v0.0.2

Published

A CLI tool to figure out the least disruptive Prettier config to add to an existing project.

Downloads

5

Readme

prettier-detect

NPM Package prettier-detect License: MIT

A CLI tool to figure out the least disruptive Prettier config to add to an existing project.

Overview

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.

Getting started

Dependencies

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.

Installation

Invoke directly:

npx prettier-detect

Or, install globally for access across your system:

npm install --global prettier-detect

Usage

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.

CLI

Command: prettier-detect

Get 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 | |

API

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>

Maintainers

List maintainer(s) for a repository, along with one way of contacting them (e.g. GitHub link or email).

Acknowledgments

State anyone or anything that significantly helped with the development of your project. State public contact hyper-links if applicable.

Contributing

Issues and pull requests are welcome.

License

MIT © Eric Mika