Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Commit 2e5bb94

Browse files
committed
infra - Add prettier as a pre-commit hook and verify in CI
1 parent 9e5b52e commit 2e5bb94

File tree

3 files changed

+670
-97
lines changed

3 files changed

+670
-97
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ script:
3535
# Output useful info for debugging.
3636
- node --version
3737
- yarn --version
38+
# Make sure prettier has ran on all files.
39+
- yarn format-check
3840
# Make sure we can actually build the examples.
3941
- yarn run build-examples
4042
# Run tests

package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
"examples": "webpack-dev-server --config examples/webpack.config.js --no-info --content-base examples",
3535
"examples-server": "babel-node examples/server.js",
3636
"flow": "flow check",
37+
"format": "prettier --write \"{src,examples}/**/*.js\"",
38+
"format-check": "prettier --list-different \"{src,examples}/**/*.js\"",
3739
"eslint": "eslint .",
3840
"fixlint": "npm run eslint -- --fix",
3941
"lint": "builder concurrent --buffer eslint flow",
@@ -63,7 +65,9 @@
6365
"babel-preset-stage-1": "^6.22.0",
6466
"builder": "^3.2.3",
6567
"exenv": "^1.2.1",
68+
"husky": "^1.2.0",
6669
"inline-style-prefixer": "^4.0.0",
70+
"lint-staged": "^8.1.0",
6771
"prop-types": "^15.5.8",
6872
"publishr": "^1.0.0",
6973
"rimraf": "^2.6.1",
@@ -105,7 +109,7 @@
105109
"node-libs-browser": "^2.0.0",
106110
"nodemon": "^1.11.0",
107111
"object-assign": "^4.1.1",
108-
"prettier": "^0.22.0",
112+
"prettier": "^1.15.3",
109113
"react": "^16.2.0",
110114
"react-dom": "^16.2.0",
111115
"react-test-renderer": "^16.2.0",
@@ -127,5 +131,17 @@
127131
"scripts": {
128132
"postinstall": ""
129133
}
134+
},
135+
"husky": {
136+
"hooks": {
137+
"pre-commit": "lint-staged"
138+
}
139+
},
140+
"lint-staged": {
141+
"*.js": [
142+
"yarn format",
143+
"yarn fixlint",
144+
"git add"
145+
]
130146
}
131147
}

0 commit comments

Comments
 (0)