Feature/set up husky and pre-commit hook for linting and format check (#3867)
* Set up husky and pre-commit hook for linting and format check * Update changelog --------- Signed-off-by: Dominik Willner <th33xitus@gmail.com>pull/3876/head
parent
f3e2091ff4
commit
fd26253e7a
@ -0,0 +1,6 @@
|
||||
# Run linting and stop the commit process if any errors are found
|
||||
# --quiet suppresses warnings (temporary until all warnings are fixed)
|
||||
npm run lint --quiet || exit 1
|
||||
|
||||
# Check formatting on modified and uncommitted files, stop the commit if issues are found
|
||||
npm run format:check --uncommitted || exit 1
|
@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Will check if "npm run format" is run before executing.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
|
||||
echo "Running npm run format"
|
||||
|
||||
# Run the command and loop over its output
|
||||
FILES_TO_STAGE=""
|
||||
i=0
|
||||
while IFS= read -r line; do
|
||||
# Process each line here
|
||||
((i++))
|
||||
if [ $i -le 2 ]; then
|
||||
continue
|
||||
fi
|
||||
if [[ $line == Done* ]]; then
|
||||
break
|
||||
fi
|
||||
FILES_TO_STAGE="$FILES_TO_STAGE $line"
|
||||
|
||||
done < <(npm run format)
|
||||
git add $FILES_TO_STAGE
|
||||
echo "Files formatted. Committing..."
|
Loading…
Reference in new issue