npm install --save-dev prettier
format.sh
#!/bin/bash
set -e
npx prettier --write . --ignore-path .gitignore
package.json
{
"scripts": {
"format": "bash scripts/format.sh"
}
}
npm install --save-dev husky pretty-quick
prepare.sh
#!/bin/bash
set -e
npx husky install
package.json
{
"scripts": {
"format": "bash scripts/format.sh",
"prepare": "bash scripts/prepare.sh"
}
}
npm run prepare
npx husky add .husky/pre-commit
.husky/pre-commit
npx pretty-quick --staged
.husky/pre-commit should be executable.
chmod +x pre-commit