Created
January 9, 2025 16:08
-
-
Save fazlurr/66a6a7580b54d6a795fe2bb9d396a333 to your computer and use it in GitHub Desktop.
Precommit Lint Staged File
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
#!/bin/bash | |
clear | |
fileList=$(git diff --diff-filter=d --cached --name-only | grep -E '\.(js|vue)$') | |
if [ ${#fileList} -lt 1 ]; then | |
echo -e "You have no staged .js or .vue files to test\n" | |
exit | |
fi | |
npx eslint ${fileList[*]} "$@" | |
if [ $? -ne 0 ]; then | |
echo -e "\nPlease fix the above linting issues before committing.\n" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From: https://gist.github.com/dahjelle/8ddedf0aebd488208a9a7c829f19b9e8?permalink_comment_id=3218493#gistcomment-3218493