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

v0.3.0

Published

Scripts to help move/maintain your code on Prettier.

Downloads

25

Readme

prettier-scripts

$ yarn add --dev prettier-scripts

prettier-scripts is a collection of command line executables that makes adopting Prettier into your code base a little bit easier.

Installation

$ yarn add --dev prettier-scripts

Or if you prefer npm:

$ npm install --dev prettier-scripts

IMPORTANT: prettier-scripts does not install prettier or prettier-eslint for you. Your project must have those installed already.

Scripts

prettier-scripts provides two executables currently, one to check your code base and one to format files:

$ ./node_modules/.bin/prettier-scripts-check ...

and

$ ./node_modules/.bin/prettier-scripts-write ...

Both scripts take the same set of arguments. Any argument that Prettier's CLI accepts will be passed to Prettier accordingly.

prettier-scripts-check will exit with the correct exit code based on if Prettier succeeded or failed, so it's perfect to run as a pre-commit hook or on your CI server.

There is one exception to the Prettier CLI; rather than pass a glob of files as a standalone option, you have to pass them through the --targets argument. This is because there are two ways to give prettier-scripts some files; either by telling it to use git to calculate the changed files, or by passing a glob to --targets.

For example:

  • Run prettier on only changed files and write them: prettier-scripts-write --changed
  • Run prettier on all targets and write them: prettier-scripts-write --targets 'src/**/*.js'

If you only wanted to check the files, you can swap prettier-scripts-write for prettier-scripts-check.

There are also some additional flags that prettier-scripts uses:

  • --prettier-eslint: Uses prettier-eslint-cli, rather than Prettier directly.
  • --filter-changed: When you are using --changed, you can also pass --filter-changed to filter which changed files are passed through. For example, you would pass --filter-changed '*.js' to filter the changed files to just JavaScript.

Log Level

By default the level of logging is set to warn. You can change how much or little is logged by prettier-scripts via LOG_LEVEL:

$ LOG_LEVEL=debug prettier-scripts-check --changed

You can set the log level to:

  • trace
  • debug
  • info
  • warn (default)
  • error

Examples

Check only changed files, and use no semi colons:

$ ./node_modules/.bin/prettier-scripts-check --changed --no-semi

Check only changed JavaScript files:

$ ./node_modules/.bin/prettier-scripts-check --changed --filter-changed '**/*.js'

Check all targets, and use no semi colons:

$ ./node_modules/.bin/prettier-scripts-check --no-semi --targets 'src/**/*.js'

Set print-width to 120 and write all files:

$ ./node_modules/.bin/prettier-scripts-write --print-width 120 --targets 'src/**/*.js'

Check your entire project in an npm script for use on CI

// package.json
{
  "scripts": {
    "prettier-check-all": "prettier-scripts-check --targets 'src/**/*.js' --no-semi --trailing-comma es5"
  }
}