Skip to content

Instantly share code, notes, and snippets.

@wesbos
Created July 4, 2016 18:55
Show Gist options
  • Select an option

  • Save wesbos/8aec9d2ff7f7cf9dd65ca2c20d5dfc23 to your computer and use it in GitHub Desktop.

Select an option

Save wesbos/8aec9d2ff7f7cf9dd65ca2c20d5dfc23 to your computer and use it in GitHub Desktop.

Revisions

  1. wesbos created this gist Jul 4, 2016.
    20 changes: 20 additions & 0 deletions commit-msg
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/bin/bash
    files=$(git diff --cached --name-only | grep '\.jsx\?$')

    # Prevent ESLint help message if no files matched
    if [[ $files = "" ]] ; then
    exit 0
    fi

    failed=0
    for file in ${files}; do
    git show :$file | eslint $file
    if [[ $? != 0 ]] ; then
    failed=1
    fi
    done;

    if [[ $failed != 0 ]] ; then
    echo "🚫🚫🚫 ESLint failed, git commit denied!"
    exit $failed
    fi