Skip to content

Commit 8514966

Browse files
authored
Merge pull request #26 from drivecore/feature/issue-25-add-husky-precommit-hook
Fix #25: Add Husky pre-commit hook to ensure project builds
2 parents 539a05e + 2296124 commit 8514966

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

.husky/pre-commit

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
echo "Running pre-commit checks..."
5+
npm run pre-commit-check

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ We welcome contributions to improve the documentation:
7171
5. Push to the branch (`git push origin feature/amazing-improvement`)
7272
6. Open a Pull Request
7373

74+
### Pre-commit Hooks
75+
76+
This repository uses Husky to run pre-commit hooks that ensure code quality. When you commit changes, the following checks will run automatically:
77+
78+
- Building the project to ensure there are no build errors or warnings
79+
80+
If the build fails, your commit will be aborted. Fix the issues and try committing again.
81+
82+
To manually run the checks:
83+
84+
```bash
85+
npm run pre-commit-check
86+
```
87+
7488
## License
7589

7690
This project is licensed under the MIT License - see the LICENSE file for details.

package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"write-translations": "docusaurus write-translations",
1414
"write-heading-ids": "docusaurus write-heading-ids",
1515
"typecheck": "tsc",
16-
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
16+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
17+
"prepare": "husky",
18+
"pre-commit-check": "npm run build"
1719
},
1820
"dependencies": {
1921
"@docusaurus/core": "3.7.0",
@@ -33,6 +35,8 @@
3335
"@typescript-eslint/parser": "^7.0.0",
3436
"eslint": "^8.56.0",
3537
"eslint-plugin-react": "^7.33.2",
38+
"husky": "^9.1.7",
39+
"lint-staged": "^15.4.3",
3640
"typescript": "~5.6.2"
3741
},
3842
"browserslist": {
@@ -49,5 +53,10 @@
4953
},
5054
"engines": {
5155
"node": ">=18.0"
56+
},
57+
"lint-staged": {
58+
"*.{js,jsx,ts,tsx}": [
59+
"eslint --fix"
60+
]
5261
}
53-
}
62+
}

0 commit comments

Comments
 (0)