Skip to content

Commit 6ee7d03

Browse files
authored
Add Lint-staged and Husky to run lint and prettier pre-commit hook (#101)
1 parent 58faa27 commit 6ee7d03

File tree

3 files changed

+247
-3
lines changed

3 files changed

+247
-3
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm exec lint-staged

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66
"scripts": {
77
"clean": "rm -rf .nyc_output coverage dist",
88
"test": "nyc mocha 'src/**/*.test.ts' --require=tsx",
9-
"lint": "eslint 'src/**/*.ts'",
10-
"prettier": "prettier --write .",
9+
"lint": "eslint --fix 'src/**/*.ts'",
10+
"format": "prettier --write --ignore-unknown .",
1111
"coverage": "nyc report --reporter html && open coverage/index.html",
12-
"coverage:check": "nyc check-coverage --lines 90 --branches 80 --statements 90"
12+
"coverage:check": "nyc check-coverage --lines 90 --branches 80 --statements 90",
13+
"prepare": "husky"
14+
},
15+
"lint-staged": {
16+
"**/*": [
17+
"pnpm lint",
18+
"pnpm format"
19+
]
1320
},
1421
"packageManager": "pnpm@10.12.1",
1522
"devDependencies": {
@@ -21,6 +28,8 @@
2128
"eslint": "^9.31.0",
2229
"eslint-config-prettier": "^10.1.5",
2330
"globals": "^16.3.0",
31+
"husky": "^9.1.7",
32+
"lint-staged": "^16.1.2",
2433
"mocha": "^11.7.1",
2534
"nyc": "^17.1.0",
2635
"prettier": "3.6.2",

0 commit comments

Comments
 (0)