Skip to content

Instantly share code, notes, and snippets.

@apostololeg
Forked from kentcdodds/eslint-changed.sh
Last active July 4, 2018 12:26
Show Gist options
  • Save apostololeg/e06bafd6072842c50a2789156b1028f3 to your computer and use it in GitHub Desktop.
Save apostololeg/e06bafd6072842c50a2789156b1028f3 to your computer and use it in GitHub Desktop.
Shell script to lint only changed files to be used as a githook (specific to my project)
#!/usr/bin/env bash
set -e
NM_BIN=./node_modules/.bin
echo "Linting changed files"
SRC_FILES=$(git diff --staged --diff-filter=ACMTUXB --name-only -- '*.js' | grep -v '\.test\|mock\|e2e\.js$') && x=1
function lint() {
if [ "$2" ]; then
echo "Linting changed $1 files"
$NM_BIN/eslint $2 -c other/${1}.eslintrc
else
echo "No $1 files changed"
fi
}
lint "app" $SRC_FILES;
echo "⚡️ changed files passed linting! ⚡️"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment