Skip to content

Instantly share code, notes, and snippets.

@muhammadghazali
Last active June 25, 2018 15:37
Show Gist options
  • Save muhammadghazali/5511c2ce67d7db08a193ad5ebe73defa to your computer and use it in GitHub Desktop.
Save muhammadghazali/5511c2ce67d7db08a193ad5ebe73defa to your computer and use it in GitHub Desktop.
Setup prettier pre-commit Hook. This bash script is suitable if you have a project without prettier integration and interested to add prettier into your current development workflow.
#!/usr/bin/env bash
npm i -D --save-exact prettier
npm i -D pretty-quick husky --save
# to manipulate the existing package.json file
npm i -g json
# add precommit to package.json scripts
json -I -f package.json -e 'this.scripts.precommit="pretty-quick --staged"'
# add prettier config file
touch .prettierrc
echo '{
"singleQuote": true
}
' >> .prettierrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment