From a235694c7bb02317f1143be02855b10c1d60a06e Mon Sep 17 00:00:00 2001
From: "Kent C. Dodds" <kent+github@doddsfamily.us>
Date: Tue, 7 Mar 2017 16:52:43 -0800
Subject: [PATCH] Add lint-staged + husky for prettier auto-formatting on
 commit (#1759)

---
 PULL_REQUEST_TEMPLATE.md |  2 --
 package.json             | 11 ++++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
index 74c36d4c9..87acf9c2f 100644
--- a/PULL_REQUEST_TEMPLATE.md
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -4,7 +4,5 @@ If you changed any code, there are just two more things to do:
 
 * Provide us with clear instructions on how you verified your changes work. Bonus points for screenshots!
 
-* If you changed any code, run `npm run format` in the root folder, and commit and push the changes.
-
 Happy contributing!
 -->
diff --git a/package.json b/package.json
index c95e75ee5..9ca7cfc03 100644
--- a/package.json
+++ b/package.json
@@ -9,12 +9,21 @@
     "publish": "tasks/release.sh",
     "start": "node packages/react-scripts/scripts/start.js",
     "test": "node packages/react-scripts/scripts/test.js --env=jsdom",
-    "format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'"
+    "format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
+    "precommit": "lint-staged"
   },
   "devDependencies": {
     "eslint": "3.16.1",
+    "husky": "^0.13.2",
     "lerna": "2.0.0-beta.38",
     "lerna-changelog": "^0.2.3",
+    "lint-staged": "^3.3.1",
     "prettier": "^0.21.0"
+  },
+  "lint-staged": {
+    "*.js": [
+      "prettier --trailing-comma es5 --single-quote --write",
+      "git add"
+    ]
   }
 }
-- 
GitLab