forked from mirrors/gecko-dev
Differential Revision: https://phabricator.services.mozilla.com/D37761 --HG-- extra : moz-landing-system : lando
33 lines
1 KiB
Bash
Executable file
33 lines
1 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Recommended pre-commit git hook for activity-stream github repo
|
|
#
|
|
# Install by executing
|
|
#
|
|
# ln -s ../../hooks/pre-commit .git/hooks/pre-commit
|
|
#
|
|
# at the top-level of the activity-stream github repo.
|
|
#
|
|
# Runs `eslint --fix` on all selected files, which, given our current
|
|
# prettier configuration, means prettifying these files as well. The
|
|
# commit will be aborted if eslint exits with a failure code.
|
|
#
|
|
# Based on the example script in the prettier docs at
|
|
# https://prettier.io/docs/en/precommit.html
|
|
|
|
FILES=$(git diff --cached --name-only --diff-filter=ACM "*.js" "*.jsx" "*.jsm" | sed 's| |\\ |g')
|
|
[ -z "$FILES" ] && exit 0
|
|
|
|
echo "$FILES" | xargs ./node_modules/.bin/eslint --cache --fix
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "eslint found errors but was unable to fix them all with --fix."
|
|
echo "Please check the output, resolve any issues, and retry."
|
|
echo "If you want to commit anyway, pass the --no-verify flag to git commit."
|
|
exit -1
|
|
fi
|
|
|
|
# Add back the modified/prettified files to staging
|
|
echo "$FILES" | xargs git add
|
|
|
|
exit 0
|