Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
chore: create githooks to check formatting and linting (#56)
Browse files Browse the repository at this point in the history
* chore: pre-commit and pre-push hooks added

* docs: removed yarn lint from PR template
  • Loading branch information
benceharomi authored Oct 31, 2023
1 parent cd5b208 commit 41f51f9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

CYAN='\033[0;36m'
NC='\033[0m' # No Color
RED='\033[0;31m'

# Check that the code is formatted in the given directory provided in the first argument
function check_prettier {
if ! yarn prettier:check; then
echo "${RED}Commit error! Cannot commit unformatted code!${NC}"
echo "Prettier errors found. Please format the code via ${CYAN}yarn prettier:fix${NC}!"
exit 1
fi
}

check_prettier
16 changes: 16 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

CYAN='\033[0;36m'
NC='\033[0m' # No Color
RED='\033[0;31m'

# Checking that the code is linted and formatted in the given directory provided in the first argument
function check_lint {
if ! yarn lint:check; then
echo "${RED}Push error! Cannot push unlinted code!${NC}"
echo "Lint errors found. Please lint the code via ${CYAN}yarn lint:fix${NC} and/or fix the errors manually!"
exit 1
fi
}

check_lint
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@
- [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been linted and formatted via `yarn lint:fix`.

0 comments on commit 41f51f9

Please sign in to comment.