DEV Community

Sosuke Suzuki
Sosuke Suzuki

Posted on

Setting up Prettier and Husky automatically, with prettier-configure

(Please put a star!⭐)

I developed prettier-configure. It enabel to set up Prettier and Husky automatically.


It assumes that package.json already exists in your current directory.

You have not to install prettier-configure. You can run it via npx like below:

npx prettier-configure

If you run it, prettier-configure execs the following three steps:

1. Install Prettier and Husky to your devDependencies via yarn (or npm).

prettire-configure installs Prettier and Husky to your devDependencies. You can choose your favorite package manager via manager argument option.

npx prettier-configure --manager=npm

2. Add a npm script for format with Prettier and config for Husky to your package.json.

prettier-configure inserts "scripts" and "husky" to your package.json.

  "scripts": {
    "format": "prettier --write "**/*.{js,jsx,ts,tsx,md,json,yaml,html}""
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged"

(caution: If your package.json has "scripts" already, it will be rewrote.)

3. Create .prettierrc.yaml and .prettierignore in your current directory.

Create files with my favorite default settings. If other people want to use this tool, I'll enable that you can change default settings.


trailingComma: 'all'
singleQuote: true
tabWidth: 4



Top comments (0)