sh 用于eslint的pre-commit钩子,linting * only * staged更改。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 用于eslint的pre-commit钩子,linting * only * staged更改。相关的知识,希望对你有一定的参考价值。
#!/bin/bash
for file in $(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx)$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
fi
done
以上是关于sh 用于eslint的pre-commit钩子,linting * only * staged更改。的主要内容,如果未能解决你的问题,请参考以下文章