Skip to content

Commit 7e28d75

Browse files
authored
chore: add a pre-commit hook for linting (base#601)
* add a precommit hook for linting * test * Revert "test" This reverts commit f5329bd. * add eslintcache to gitignore
1 parent 344775d commit 7e28d75

File tree

5 files changed

+370
-6
lines changed

5 files changed

+370
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@ package-lock.json
6969
schema.graphql
7070
persisted_queries.json
7171
**/*.graphql.ts
72+
73+
# eslint
74+
.eslintcache

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"license": "Apache-2.0",
77
"scripts": {
88
"build": "yarn workspaces foreach run build",
9-
"lint": "yarn workspaces foreach run lint"
9+
"lint": "yarn workspaces foreach run lint",
10+
"postinstall": "husky install",
11+
"prepublishOnly": "pinst --disable",
12+
"postpublish": "pinst --enable"
1013
},
1114
"workspaces": [
1215
"apps/*",
@@ -49,8 +52,11 @@
4952
"eslint-plugin-react-perf": "^3.3.1",
5053
"eslint-plugin-relay": "^1.8.3",
5154
"eslint-plugin-simple-import-sort": "^8.0.0",
55+
"husky": ">=6",
5256
"jest": "^29.4.1",
5357
"jest-environment-jsdom": "^29.4.1",
58+
"lint-staged": ">=10",
59+
"pinst": ">=2",
5460
"prettier": "^2.7.1",
5561
"react": "^18.2.0",
5662
"react-test-renderer": "18.2.0",
@@ -77,5 +83,9 @@
7783
"moment": "^2.29.4",
7884
"next": "12.2.3",
7985
"tslib": "^2.3.0"
86+
},
87+
"lint-staged": {
88+
"*.{js,jsx,ts,tsx}": "eslint --cache --fix",
89+
"*.{js,jsx,ts,tsx,css,md}": "prettier --write"
8090
}
8191
}

0 commit comments

Comments
 (0)