Skip to content

Instantly share code, notes, and snippets.

@bearzk
Last active March 3, 2020 11:26
Show Gist options
  • Save bearzk/a4fb6842dbe752c6fa5fc4b9db884e8e to your computer and use it in GitHub Desktop.
Save bearzk/a4fb6842dbe752c6fa5fc4b9db884e8e to your computer and use it in GitHub Desktop.
[lintStaged] #bash #lint
#!/bin/sh
# this script will run eslint against staged files
# in staged flies
# find (M)odified and (A)dded file names,
# find those conotains "src" or "test"
toLint=$(git diff --name-status --cached | grep -E "^[M|A]" | awk '{print $2}' | grep -E "src|test")
if [ -z "$toLint" ]; then
echo "no need to do lintng."
exit 0
fi
echo "checking ${toLint}"
npx eslint $toLint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment