Skip to content

Commit a522e77

Browse files
committed
chore: 🤖 rm husky, add lefthook
1 parent 1d6723e commit a522e77

File tree

7 files changed

+555
-3934
lines changed

7 files changed

+555
-3934
lines changed

.eslintrc.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

.husky/commit-msg

Lines changed: 0 additions & 4 deletions
This file was deleted.

.husky/pre-commit

Lines changed: 0 additions & 4 deletions
This file was deleted.

biome.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
33
"files": {
4-
"ignoreUnknown": true,
5-
"include": ["./**/*.{js,jsx,ts,tsx,json,yml,yaml}"]
4+
"ignoreUnknown": true
65
},
76
"vcs": {
87
"enabled": true,

lefthook.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# yaml-language-server:$schema=./node_modules/lefthook/schema.json
2+
# https://evilmartians.github.io/lefthook/configuration/
3+
4+
pre-commit:
5+
piped: true
6+
jobs:
7+
- name: Linting & Formatting
8+
group:
9+
parallel: true
10+
jobs:
11+
- name: biome
12+
glob: "*.{ts,tsx,js,jsx,mjs,mts,json,jsonc,css}"
13+
run: pnpm biome check --fix {staged_files} --reporter summary
14+
stage_fixed: true
15+
16+
# - name: QA
17+
# group:
18+
# parallel: true
19+
# jobs:
20+
# - name: typecheck
21+
# glob: "*.{ts,tsx}"
22+
# run: pnpm tsc
23+
# - name: test
24+
# glob: "*.{ts,tsx,js,jsx,mjs,mts,json,css,scss}"
25+
# run: pnpm nx affected -t prod test:ci --files={staged_files}
26+
27+
prepare-commit-msg:
28+
commands:
29+
commit:
30+
skip:
31+
- run: node -e "require('fs').readFileSync('.git/COMMIT_EDITMSG','utf8').trim()||process.exit(1)"
32+
interactive: true
33+
run: pnpm git-cz --hook
34+
env:
35+
LEFTHOOK: "0"
36+
37+
commit-msg:
38+
commands:
39+
commitlint:
40+
run: pnpm commitlint --edit {1}
41+
42+
post-merge:
43+
follow: true
44+
commands:
45+
check-pnpm-lock:
46+
run: |
47+
if git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep pnpm-lock.yaml; then
48+
echo pnpm-lock.yaml 已变更,请运行 pnpm install 以保持依赖一致
49+
fi
50+
51+
post-checkout:
52+
follow: true
53+
commands:
54+
check-pnpm-lock:
55+
run: |
56+
if [ {3} -eq 1 ]; then
57+
if git diff --quiet {1} {2} -- pnpm-lock.yaml; then
58+
echo pnpm-lock.yaml 已变更,请运行 pnpm install 以保持依赖一致
59+
fi
60+
fi

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"build": "pnpm -r --filter=./packages/* run build",
1919
"test": "jest",
2020
"coveralls": "jest --coverage --coverageReporters=text-lcov | coveralls",
21-
"lint": "eslint --ignore-pattern **/__tests__/* --ignore-pattern **/demo/* \"packages/*/src/**/*.{ts,tsx}\" --cache",
22-
"pretty": "biome format --fix --staged",
21+
"lint": "biome check --fix .",
2322
"build:doc": "set NODE_OPTIONS=--openssl-legacy-provider && dumi build",
2423
"build:doc-github": "node scripts/build-with-relative-paths.js",
2524
"pub:doc-surge": "surge ./dist --domain ahooks.js.org",
@@ -28,8 +27,9 @@
2827
"pub": "pnpm run build && pnpm -r --filter=./packages/* publish",
2928
"pub:beta": "pnpm run build && pnpm -r --filter=./packages/* publish --tag beta",
3029
"preinstall": "npx only-allow pnpm",
31-
"prepare": "husky install",
32-
"test:strict": "cross-env REACT_MODE=strict jest"
30+
"prepare": "node -e \"try { require('child_process').execSync('git config --unset core.hookspath', {stdio: 'ignore'}); } catch (e) {}\" && lefthook install",
31+
"test:strict": "cross-env REACT_MODE=strict jest",
32+
"commit": "git add -A && git commit --no-edit"
3333
},
3434
"devDependencies": {
3535
"@ant-design/icons": "^5.3.0",
@@ -44,25 +44,23 @@
4444
"@types/jest": "^29.4.0",
4545
"@types/mockjs": "^1.0.7",
4646
"@types/react-router": "^5.1.19",
47-
"@umijs/fabric": "^2.1.0",
4847
"antd": "^5.14.2",
4948
"babel-plugin-import": "^1.12.0",
5049
"coveralls": "^3.1.1",
5150
"cross-env": "^7.0.3",
5251
"del": "^5.1.0",
5352
"dumi": "^1.1.48",
54-
"eslint": "^8.56.0",
55-
"eslint-plugin-react-hooks": "^4.6.0",
5653
"fast-glob": "^3.2.11",
5754
"fs-extra": "^10.0.1",
55+
"git-cz": "^4.9.0",
5856
"gray-matter": "^4.0.3",
5957
"gulp": "^4.0.2",
6058
"gulp-babel": "^8.0.0",
6159
"gulp-typescript": "^6.0.0-alpha.1",
62-
"husky": "^8.0.0",
6360
"jest": "^29.4.1",
6461
"jest-environment-jsdom": "^29.4.1",
6562
"jest-localstorage-mock": "^2.4.18",
63+
"lefthook": "^1.11.11",
6664
"mockjs": "^1.1.0",
6765
"react": "^18.2.0",
6866
"react-dom": "^18.2.0",

0 commit comments

Comments
 (0)