diff --git a/.husky/pre-commit b/.husky/pre-commit index c1122febe..8ce8cca22 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1,16 @@ -node tools/validate-eslint.js \ No newline at end of file +#!/usr/bin/env sh +set -e + +node tools/validate-eslint.js + +tmpfile="$(mktemp)" +git diff --cached --name-only -z --diff-filter=ACMR -- \ + '*.js' '*.mjs' '*.cjs' '*.jsx' '*.ts' '*.tsx' '*.vue' \ + > "$tmpfile" + +if [ -s "$tmpfile" ]; then + xargs -0 eslint --fix < "$tmpfile" + xargs -0 git add < "$tmpfile" +fi + +rm -f "$tmpfile"