-
Create your .git repository.
-
Edit
package.json
to add ascripts
,pre-commit
, andlint-staged
section, as shown below.{ "name": "example", "main": "app.js", "dependencies": { "express": "*", }, "scripts": { "pre-commit": "lint-staged" }, "pre-commit": [ "pre-commit" ], "lint-staged": { "*.js": [ "prettier --write", "git add" ] } }
-
Run the following commands:
npm install npm install prettier lint-staged pre-commit --save-dev
Last active
May 31, 2023 09:34
-
-
Save primaryobjects/9ab8d2346aa58ef6959ad357bb835963 to your computer and use it in GitHub Desktop.
How to setup prettier as a pre-commit hook for Git commits.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! This got it working for me.