Feat/add husky (#223)
# Add Husky and lint-staged for automated code quality checks ## Description This PR adds Husky Git hooks and lint-staged to automate code quality checks during the development workflow. ## Features Added - Pre-commit hook that runs lint-staged to check files before committing - Pre-push hook that runs tests and type checking before pushing - Configuration for lint-staged to format and lint different file types - Documentation explaining the Husky setup and usage - Updated README.md with information about Git hooks ## Benefits - Ensures consistent code style across the project - Prevents pushing code with failing tests or type errors - Reduces the need for style-related code review comments - Improves overall code quality ## Implementation Details - Added Husky and lint-staged as dev dependencies - Created pre-commit and pre-push hooks - Added configuration for lint-staged - Added documentation in HUSKY.md - Updated README.md with a new section on Git hooks ## Testing The hooks have been tested locally and work as expected: - Pre-commit hook runs ESLint and Prettier on staged files - Pre-push hook runs tests and type checking I have read the CLA Document and I hereby sign the CLA --------- Signed-off-by: Alpha Diop <alphakhoss@gmail.com>
This commit is contained in:
32
codex-cli/.husky/_/husky.sh
Normal file
32
codex-cli/.husky/_/husky.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env sh
|
||||
if [ -z "$husky_skip_init" ]; then
|
||||
debug () {
|
||||
if [ "$HUSKY_DEBUG" = "1" ]; then
|
||||
echo "husky (debug) - $1"
|
||||
fi
|
||||
}
|
||||
|
||||
readonly hook_name="$(basename -- "$0")"
|
||||
debug "starting $hook_name..."
|
||||
|
||||
if [ "$HUSKY" = "0" ]; then
|
||||
debug "HUSKY env variable is set to 0, skipping hook"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f ~/.huskyrc ]; then
|
||||
debug "sourcing ~/.huskyrc"
|
||||
. ~/.huskyrc
|
||||
fi
|
||||
|
||||
readonly husky_skip_init=1
|
||||
export husky_skip_init
|
||||
sh -e "$0" "$@"
|
||||
exitCode="$?"
|
||||
|
||||
if [ $exitCode != 0 ]; then
|
||||
echo "husky - $hook_name hook exited with code $exitCode (error)"
|
||||
fi
|
||||
|
||||
exit $exitCode
|
||||
fi
|
||||
5
codex-cli/.husky/pre-commit
Normal file
5
codex-cli/.husky/pre-commit
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
# Run lint-staged to check files that are about to be committed
|
||||
npm run pre-commit
|
||||
5
codex-cli/.husky/pre-push
Normal file
5
codex-cli/.husky/pre-push
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
# Run tests and type checking before pushing
|
||||
npm test && npm run typecheck
|
||||
Reference in New Issue
Block a user