Skip to content

Commit 2490026

Browse files
committed
main 🧊 add lefthook
1 parent 3d7c4ca commit 2490026

119 files changed

Lines changed: 1528 additions & 5679 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.husky/pre-commit

Lines changed: 0 additions & 19 deletions
This file was deleted.
File renamed without changes.

.lefthook/core-checks

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
if git diff --quiet HEAD -- packages/core; then
4+
echo "No changes in packages/core. Skipping build."
5+
exit 0
6+
fi
7+
8+
echo "Running tests for packages/core..."
9+
pnpm --dir packages/core exec vitest run || exit 1
10+
11+
echo "Running build:js..."
12+
pnpm core:build:js || exit 1
13+
14+
git add packages/core/src/bundle
15+
git add packages/cli/src/registry
16+
echo "Built files added to git."

.lefthook/lint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
[ $# -eq 0 ] && exit 0
3+
pnpm exec eslint --fix "$@" && pnpm exec prettier --write "$@"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pnpm unit-test # run unit tests across all packages
5858
pnpm format # format with prettier
5959
```
6060

61-
7. commit your changes (a `husky` + `lint-staged` pre-commit hook will lint and format staged files automatically)
61+
7. commit your changes (the `lefthook` pre-commit hook will lint and format staged files automatically)
6262
8. push your feature branch and open a [Pull Request](https://github.com/siberiacancode/reactuse/compare) targeting `main`
6363
9. link your PR to the issue using a [closing keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) or describe the motivation and changes in the comment (example: `fix #74`)
6464
10. wait until a maintainer reviews it

lefthook.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
pre-commit:
2+
parallel: true
3+
commands:
4+
lint-core:
5+
glob: 'packages/core/**/*.{js,ts,tsx}'
6+
run: sh .lefthook/lint {staged_files}
7+
stage_fixed: true
8+
9+
lint-cli:
10+
glob: 'packages/cli/**/*.{js,ts}'
11+
run: pnpm --dir packages/cli run type && sh .lefthook/lint {staged_files}
12+
stage_fixed: true
13+
14+
core-checks:
15+
run: sh .lefthook/core-checks
16+
17+
commit-msg:
18+
commands:
19+
branch-prefix:
20+
run: sh .lefthook/commit-msg {1}

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@
3131
"lint": "pnpm --recursive lint",
3232
"format": "prettier --write .",
3333
"unit-test": "pnpm --recursive run unit-test",
34-
"lint-staged": "pnpm --recursive run lint-staged",
35-
"prepare": "husky"
34+
"prepare": "lefthook install"
3635
},
3736
"devDependencies": {
37+
"@siberiacancode/tsconfig": "1.2.0",
3838
"@siberiacancode/eslint": "2.17.6",
3939
"@siberiacancode/prettier": "^1.7.0",
40-
"@types/node": "^26.0.0",
41-
"husky": "^9.1.7",
42-
"lucide-react": "1.21.0",
43-
"lint-staged": "^17.0.8",
40+
"@types/node": "^26.1.0",
41+
"lefthook": "^2.1.9",
42+
"lucide-react": "1.23.0",
4443
"prettier-plugin-tailwindcss": "0.8.0",
4544
"typescript": "^6.0.3"
4645
}

packages/cli/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,5 @@
5656
"cross-env": "^10.1.0",
5757
"tsdown": "^0.20.3",
5858
"tsx": "^4.21.0"
59-
},
60-
"lint-staged": {
61-
"*.{js,ts}": [
62-
"eslint --fix",
63-
"prettier --write"
64-
]
6559
}
6660
}

packages/cli/tsconfig.json

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "@siberiacancode/tsconfig/tsconfig.bundler.json",
34
"compilerOptions": {
45
"composite": false,
5-
"module": "ESNext",
66
"paths": {
77
"@/*": ["./src/*"]
88
},
9-
"resolveJsonModule": true,
10-
"strict": true,
11-
"noUnusedLocals": false,
12-
"noUnusedParameters": false,
13-
"declaration": true,
14-
"declarationMap": true,
15-
"inlineSources": false,
16-
"esModuleInterop": true,
17-
"forceConsistentCasingInFileNames": true,
18-
"preserveWatchOutput": true,
19-
"isolatedModules": true,
20-
"skipLibCheck": true
9+
"allowJs": true,
10+
"sourceMap": true
2111
},
22-
"include": ["src"],
2312
"exclude": ["node_modules"]
24-
}
13+
}

packages/core/package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
"scripts": {
5050
"prepublishOnly": "pnpm unit-test run && pnpm build",
5151
"build": "shx rm -rf dist && vite build",
52-
"build:js": "tsc --project tsconfig.build.json && prettier --write src/bundle",
52+
"build:js": "tsc --project tsconfig.build.json && pnpm prettier --write src/bundle",
5353
"lint": "eslint . --fix",
5454
"lint-inspector": "npx @eslint/config-inspector@latest",
5555
"format": "prettier --write .",
56-
"pretty": "pnpm lint && pnpm format",
57-
"unit-test": "vitest",
58-
"lint-staged": "lint-staged"
56+
"type": "tsc --noEmit",
57+
"pretty": "pnpm type && pnpm lint && pnpm format",
58+
"unit-test": "vitest"
5959
},
6060
"peerDependencies": {
6161
"@types/react": "^18 || ^19",
@@ -83,11 +83,5 @@
8383
"vite": "^8.0.16",
8484
"vite-plugin-dts": "^5.0.2",
8585
"vitest": "^4.1.9"
86-
},
87-
"lint-staged": {
88-
"*.{js,ts,tsx}": [
89-
"eslint --fix",
90-
"prettier --write"
91-
]
9286
}
9387
}

0 commit comments

Comments
 (0)