Skip to content

Commit

Permalink
chore: add TREZOR_PRE_COMMIT_ESLINT_SKIP global flax to skip pre-comm…
Browse files Browse the repository at this point in the history
…it hook for ESLint
  • Loading branch information
peter-sanderson committed Dec 17, 2024
1 parent 50584f4 commit e0fd625
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .husky/eslint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#!/bin/bash

GREEN='\033[0;32m'
NC='\033[0m' # No Color

if [ "$TREZOR_PRE_COMMIT_ESLINT_SKIP" == "true" ]; then
echo "Skipping eslint pre-commit hook, do: 'export TREZOR_PRE_COMMIT_ESLINT_SKIP=false' to re-enable it."
exit 0
fi

# This check will get all staged files that are *.js(x)/*.ts(x) files
# and run eslint on them and tries to fix them and re-add them to be committed.
# If auto-fix is possible it shall be transparent for the user.
# If some error are not fixable, the script will fail and the user will have to fix them manually.

STAGED_FILES=$(git diff --cached --name-only --diff-filter=d | grep '(\.js\|\.jsx$\|\.ts\|\.tsx)$')

echo -e "${GREEN}Running Eslint pre-commit hook, to disable it do: 'export TREZOR_PRE_COMMIT_ESLINT_SKIP=true'.${NC}"

# Exit if no files. Passing no arguments would trigger eslint for whole repo
if [ -z "$STAGED_FILES" ]; then
echo "No staged JavaScript/TypeScript files to lint."
else
echo "Linting JavaScript/TypeScript files..."
echo "$STAGED_FILES"
echo ""

Expand Down

0 comments on commit e0fd625

Please sign in to comment.