-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a27312e
commit 6ee92bc
Showing
27 changed files
with
423 additions
and
298 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
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 |
---|---|---|
@@ -1,12 +1,48 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run format:fix | ||
npm run lint:fix | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[0;33m' | ||
NC='\033[0m' | ||
|
||
git add . | ||
print_color() { | ||
printf "${!1}%s${NC}\n" "$2" | ||
} | ||
|
||
if [ -f "yarn.lock" ] || [ -f "package-lock.json" ]; then | ||
echo "Error: yarn.lock or package-lock.json is present. Please remove them before committing." | ||
exit 1 | ||
fi | ||
run_command() { | ||
print_color "YELLOW" "Running $1..." | ||
if eval "$1"; then | ||
print_color "GREEN" "$1 completed successfully." | ||
else | ||
print_color "RED" "$1 failed. Please fix the issues and try committing again." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_lock_files() { | ||
local lock_files=("yarn.lock" "package-lock.json" "pnpm-lock.yaml") | ||
local staged_files=$(git diff --cached --name-only) | ||
|
||
for file in "${lock_files[@]}"; do | ||
if echo "$staged_files" | grep -q "$file"; then | ||
print_color "RED" "Error: $file is staged for commit. Please remove it before committing." | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
main() { | ||
check_lock_files | ||
|
||
run_command "npm run format:fix" | ||
|
||
run_command "npm run lint:fix" | ||
|
||
git add . | ||
|
||
run_command "npm run lint:check" | ||
|
||
print_color "GREEN" "Pre-commit checks passed successfully!" | ||
} | ||
|
||
main |
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 |
---|---|---|
|
@@ -5,5 +5,6 @@ | |
"trailingComma": "all", | ||
"plugins": [ | ||
"prettier-plugin-tailwindcss" | ||
] | ||
], | ||
"embeddedLanguageFormatting": "off" | ||
} |
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
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
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.