The test script and pre-commit-eslint.sh
are triggered before commit.
If there are any eslint validation errors or if any unit test fails, commit will fail:
suhas:~/workspace/node-dogstatsd$ git commit
Validating Javascript with eslint:
/home/suhas/workspace/node-dogstatsd/lib/statsd.js
30:9 error 'x' is defined but never used no-unused-vars
✖ 1 problem (1 error, 0 warnings)
Failed: lib/statsd.js
Passed: test/test_statsd.js
Javascript validation completed!
Eslint validation failed! Fix the ESLint errors and try again. You can run ESLint validation manually via 'npm run eslint'.
pre-commit:
pre-commit: We've failed to pass the specified git pre-commit hooks as the `eslint`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit:
pre-commit: git commit -n (or --no-verify)
pre-commit:
pre-commit: This is ill-advised since the commit is broken.
pre-commit:
Make sure the script is executable chmod +x pre-commit-eslint.sh
.
The script was originally shared here