git filter-branch --tree-filter 'prettier --write "src/**" || echo "Error formatting, possibly invalid JS"' -- --all
Or only run on changed files for each commit
git filter-branch -f --tree-filter 'git show $GIT_COMMIT --name-status | grep "^[AM]" | grep "src/" | cut -f2 | tr "\n" " " | xargs -n1 -P8 -I "{}" prettier --write "{}" || echo "Error formatting, possibly invalid JS"' -- --all