Skip to content

Instantly share code, notes, and snippets.

@mattjared
Created January 25, 2018 21:06
Show Gist options
  • Save mattjared/f06f6afa908f523d95a951d36d1dec00 to your computer and use it in GitHub Desktop.
Save mattjared/f06f6afa908f523d95a951d36d1dec00 to your computer and use it in GitHub Desktop.
stylelint precommit hook to auto fix things that can be fixed
if [[ "$STAGED_FILES_CSS" != "" ]]; then
echo -e "\nValidating Styles:\n"
# Loop through the staged stylesheets
for FILE in $STAGED_FILES_CSS
do
"$STYLELINT" "$FILE"
if [[ "$?" == 0 ]]; then
echo -e "\t\033[32mStyleLint Passed: $FILE\033[0m"
else
echo -e "\t\033[41mStyleLint Failed: $FILE\033[0m"
PASS=false
echo -e "\t\033[41mAttempting Fix: $FILE\033[0m"
"$STYLELINT" "$FILE" --fix
if [[ "$?" == 0 ]]; then
echo -e "\t\033[32mStyleLint Passed: $FILE\033[0m"
FIX=true
else
echo -e "\t\033[41mStyleLint Failed: $FILE\033[0m"
FIX=false
fi
fi
done
echo -e "\nStyles validation completed\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment