Skip to content

Commit 563f9cb

Browse files
committed
chore: add pre-commit hook
1 parent 3797edc commit 563f9cb

File tree

3 files changed

+3583
-4647
lines changed

3 files changed

+3583
-4647
lines changed

.husky/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pnpm i --frozen-lockfile
2+
pnpm build
3+
pnpm lint-staged

package.json

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"scripts": {
1616
"test": "vitest --coverage --coverage.include src",
17-
"prepare": "npm run build",
17+
"prepare": "husky",
1818
"dev": "wrangler dev",
1919
"build:worker": "esbuild src/cloudflare-worker/index.ts --outfile=dist/worker.js --bundle --minify --format=esm --loader:.html=text --keep-names",
2020
"build:package": "esbuild src/core/index.ts --outfile=lib/index.js --bundle --format=esm --keep-names",
@@ -29,17 +29,6 @@
2929
"stats",
3030
"card"
3131
],
32-
"eslintConfig": {
33-
"root": true,
34-
"extends": [
35-
"typescript",
36-
"prettier"
37-
],
38-
"ignorePatterns": [
39-
"dist/**.js",
40-
"lib/**.js"
41-
]
42-
},
4332
"dependencies": {
4433
"itty-router": "4.0.27",
4534
"leetcode-query": "1.0.0",
@@ -54,6 +43,8 @@
5443
"esbuild": "^0.20.1",
5544
"eslint": "^8.57.0",
5645
"eslint-config-prettier": "^9.1.0",
46+
"husky": "^9.0.11",
47+
"lint-staged": "^15.2.2",
5748
"prettier": "^3.2.5",
5849
"prettier-plugin-organize-imports": "^3.2.4",
5950
"selflare": "^1.0.0",
@@ -70,5 +61,22 @@
7061
"url": "https://github.com/JacobLinCool/LeetCode-Stats-Card/issues"
7162
},
7263
"homepage": "https://github.com/JacobLinCool/LeetCode-Stats-Card#readme",
73-
"packageManager": "pnpm@8.15.4"
64+
"packageManager": "pnpm@8.15.4",
65+
"eslintConfig": {
66+
"root": true,
67+
"extends": [
68+
"typescript",
69+
"prettier"
70+
],
71+
"ignorePatterns": [
72+
"dist/**.js",
73+
"lib/**.js"
74+
]
75+
},
76+
"lint-staged": {
77+
"*.{js,ts}": [
78+
"eslint --fix",
79+
"prettier --write"
80+
]
81+
}
7482
}

0 commit comments

Comments
 (0)