Skip to content

Commit a235694

Browse files
Kent C. Doddsgaearon
Kent C. Dodds
authored andcommitted
Add lint-staged + husky for prettier auto-formatting on commit (facebook#1759)
1 parent 837f544 commit a235694

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

PULL_REQUEST_TEMPLATE.md

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ If you changed any code, there are just two more things to do:
44
55
* Provide us with clear instructions on how you verified your changes work. Bonus points for screenshots!
66
7-
* If you changed any code, run `npm run format` in the root folder, and commit and push the changes.
8-
97
Happy contributing!
108
-->

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@
99
"publish": "tasks/release.sh",
1010
"start": "node packages/react-scripts/scripts/start.js",
1111
"test": "node packages/react-scripts/scripts/test.js --env=jsdom",
12-
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'"
12+
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
13+
"precommit": "lint-staged"
1314
},
1415
"devDependencies": {
1516
"eslint": "3.16.1",
17+
"husky": "^0.13.2",
1618
"lerna": "2.0.0-beta.38",
1719
"lerna-changelog": "^0.2.3",
20+
"lint-staged": "^3.3.1",
1821
"prettier": "^0.21.0"
22+
},
23+
"lint-staged": {
24+
"*.js": [
25+
"prettier --trailing-comma es5 --single-quote --write",
26+
"git add"
27+
]
1928
}
2029
}

0 commit comments

Comments
 (0)