mirror of
https://github.com/seigler/dash-website
synced 2025-07-27 07:16:10 +00:00
js linting script for precommit hook
This commit is contained in:
parent
3e0612cf14
commit
8c55cdd3d5
1 changed files with 17 additions and 0 deletions
17
_tests/git hooks/precommit
Executable file
17
_tests/git hooks/precommit
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
jsfiles=$(git diff --cached --name-only --diff-filter=M | grep '\.js\?$')
|
||||||
|
jsfailed=0
|
||||||
|
|
||||||
|
if [[ $jsfiles != "" ]] ; then
|
||||||
|
for file in ${jsfiles}; do
|
||||||
|
git show :$file | eslint --stdin --stdin-filename "$file"
|
||||||
|
if [[ $? != 0 ]] ; then
|
||||||
|
jsfailed=1
|
||||||
|
fi
|
||||||
|
done;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $jsfailed != 0 ]] ; then
|
||||||
|
echo "🚫🚫🚫ESLint must pass before committing .js files"
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue