Add linting pre-commit hook and hook install script #86
Open
j24chung
wants to merge 1 commits from feature-80
into master
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'feature-80'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Might want to consider the case where file name can be white space. Just adding a
IFS='\n'
before the for loop is probably enough.PASS=true
# Check for flake8
I suggest using the flake8 script which gets installed in venv/bin, so that the user doesn't have to install a ilbrary globally if they don't want to.
I think we can assume git commit would be running inside virtual env, plus venv directory can be located elsewhere too
for FILE in $STAGED_FILES
do
flake8 "$FILE"
Is there a reason why we need to invoke flake8 on each file separately? If you just run
flake8
once from the root directory, it'll lint all of the source files at once.flake8 "$FILE"
if [[ "$?" == 0 ]]; then
echo -e "\t\033[32mPassed: $FILE\033[0m"
flake8 provides its own diagnostic messages for each lint error, so I don't think we need to add an extra "Passed" or "Failed" message.
echo -e "\nPython linting complete!\n"
if ! $PASS; then
echo -e "\033[41mCOMMIT FAILED:\033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again.\n"
Maybe we should change "ESLint" to "flake8"?
Reviewers