-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add husky, commitlint, lint-staged (#4)
- Loading branch information
1 parent
2852654
commit 7ec0125
Showing
12 changed files
with
780 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pnpm dlx commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Skip Husky install in production and CI | ||
if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') { | ||
process.exit(0) | ||
} | ||
const husky = (await import('husky')).default | ||
console.log(husky()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env sh | ||
|
||
BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
REGEX="^(feature|bugfix|hotfix|release|merge)\.([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)$" | ||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' | ||
echo "Branch name: ${GREEN}$BRANCH${NC}" | ||
if ! echo "$BRANCH" | grep -qE "$REGEX"; then | ||
echo "${RED}Your commit was rejected due to branching name" | ||
echo "Please rename your branch with '(feature|bugfix|hotfix|release|merge)(.<ticket>?).<subject-example>' syntax${NC}" | ||
exit 1 | ||
fi | ||
|
||
pnpm lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env sh | ||
GREEN='\033[0;32m' | ||
BLUE='\033[0;34m' | ||
NC='\033[0m' | ||
changed_files=$(git diff --name-only HEAD HEAD~ -- '*.ts' '*.js') | ||
if [ -n "$changed_files" ]; then | ||
echo "${BLUE}Running tests due to changes in the following TS/JS files:${NC}" | ||
echo "$changed_files" | ||
pnpm test | ||
else | ||
echo "${GREEN}No TS/JS files have been changed. Skipping tests.${NC}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default { extends: ['@commitlint/config-conventional'] }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
'*.ts': [ | ||
'pnpm lint', | ||
'pnpm format' | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.