diff --git a/.husky/pre-commit b/.husky/pre-commit index cb2c84d..ec320d7 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1,24 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +echo "Running pre-commit checks..." + +# Run lint-staged for code formatting and linting +echo "Running lint-staged..." pnpm lint-staged + +# Run build to ensure project builds successfully +echo "Running build checks..." +pnpm build || { + echo "❌ Build failed. Please fix the build errors before committing." + exit 1 +} + +# Run tests to ensure all tests pass +echo "Running tests..." +pnpm test || { + echo "❌ Tests failed. Please fix the failing tests before committing." + exit 1 +} + +echo "✅ All checks passed!" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ac90ad2..3cba271 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -87,8 +87,10 @@ This project and everyone participating in it is governed by our Code of Conduct - `pnpm lint`: Lints the staged files using ESLint - `pnpm format`: Formats the staged files using Prettier + - `pnpm build`: Ensures the project builds successfully + - `pnpm test`: Ensures all tests pass - If either of these commands fails due to linting errors or formatting issues, the commit will be aborted. Please fix the reported issues and try committing again. + If any of these commands fails, the commit will be aborted. Please fix the reported issues and try committing again. You can also run the lint and format commands manually at any time: @@ -164,4 +166,4 @@ This project and everyone participating in it is governed by our Code of Conduct 3. Update changelog entries 4. Tag releases appropriately -Thank you for contributing to MyCoder! 👍 +Thank you for contributing to MyCoder! 👍 \ No newline at end of file