diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..28ded28 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +echo "Running pre-commit checks..." +npm run pre-commit-check diff --git a/README.md b/README.md index df1da34..4bab85d 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,20 @@ We welcome contributions to improve the documentation: 5. Push to the branch (`git push origin feature/amazing-improvement`) 6. Open a Pull Request +### Pre-commit Hooks + +This repository uses Husky to run pre-commit hooks that ensure code quality. When you commit changes, the following checks will run automatically: + +- Building the project to ensure there are no build errors or warnings + +If the build fails, your commit will be aborted. Fix the issues and try committing again. + +To manually run the checks: + +```bash +npm run pre-commit-check +``` + ## License This project is licensed under the MIT License - see the LICENSE file for details. diff --git a/package.json b/package.json index 2228548..439c765 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,9 @@ "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "typecheck": "tsc", - "lint": "eslint . --ext .js,.jsx,.ts,.tsx" + "lint": "eslint . --ext .js,.jsx,.ts,.tsx", + "prepare": "husky", + "pre-commit-check": "npm run build" }, "dependencies": { "@docusaurus/core": "3.7.0", @@ -33,6 +35,8 @@ "@typescript-eslint/parser": "^7.0.0", "eslint": "^8.56.0", "eslint-plugin-react": "^7.33.2", + "husky": "^9.1.7", + "lint-staged": "^15.4.3", "typescript": "~5.6.2" }, "browserslist": { @@ -49,5 +53,10 @@ }, "engines": { "node": ">=18.0" + }, + "lint-staged": { + "*.{js,jsx,ts,tsx}": [ + "eslint --fix" + ] } -} +} \ No newline at end of file