From 881342cb5fa28b1bf9f17fd9f36563468f524007 Mon Sep 17 00:00:00 2001 From: Rahim Rahman Date: Fri, 5 Sep 2025 06:08:01 -0600 Subject: [PATCH] chore: error on react-hooks/exhaustive-deps during pre-commit (#9105) * chore: exhaustive-deps error * faster precommit using tsc --incremental * don't exit until both check has ran --- .gitignore | 1 + eslint.precommit.config.mjs | 15 +++++++++++++++ scripts/clean.sh | 1 + scripts/pre-commit.sh | 18 ++++++++++-------- 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 eslint.precommit.config.mjs diff --git a/.gitignore b/.gitignore index c532e55be..07b10ce5a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ env.d.ts *.apk *.aab *.ipa +.tsbuildinfo.precommit */**/compass-icons.ttf diff --git a/eslint.precommit.config.mjs b/eslint.precommit.config.mjs new file mode 100644 index 000000000..c5910fa4a --- /dev/null +++ b/eslint.precommit.config.mjs @@ -0,0 +1,15 @@ +// Pre-commit ESLint config with stricter rules +import baseConfig from './eslint.config.mjs'; + +export default [ + ...baseConfig, + { + rules: { + // Override rules to be stricter for pre-commit + 'react-hooks/exhaustive-deps': 'error', + // Add other strict rules here if needed + // 'no-console': 'error', + // '@typescript-eslint/no-unused-vars': 'error', + }, + }, +]; diff --git a/scripts/clean.sh b/scripts/clean.sh index 57bc3f651..c183b23c9 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -8,6 +8,7 @@ if command -v watchman &> /dev/null; then watchman watch-del . 2>/dev/null || echo "No watch found for this directory" fi +rm -rf .tsbuildinfo.precommit rm -rf ios/Pods rm -rf node_modules rm -rf dist diff --git a/scripts/pre-commit.sh b/scripts/pre-commit.sh index bce170f55..6c37dfc1c 100755 --- a/scripts/pre-commit.sh +++ b/scripts/pre-commit.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash jsfiles=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.js$|\.ts$|\.tsx$') +exit_code=0 if [ -z "jsfiles" ]; then exit 0 @@ -10,23 +11,24 @@ if [ -n "$jsfiles" ]; then echo "Checking lint for:" for js in $jsfiles; do echo "$js" - e=$(node_modules/.bin/eslint --quiet --fix $js) + e=$(node_modules/.bin/eslint --quiet --fix --config eslint.precommit.config.mjs $js) if [ -n "$e" ]; then echo "ERROR: Check eslint hints." echo "$e" - exit 1 # reject + exit_code=1 fi done - echo "Checking for TSC" - tsc=$(node_modules/.bin/tsc --noEmit) - if [ -n "$tsc" ]; then - echo "ERROR: Check TSC hints." + echo "Checking for TSC (fast incremental check)" + # Use incremental TypeScript checking - much faster on subsequent runs + tsc=$(node_modules/.bin/tsc --noEmit --incremental --tsBuildInfoFile .tsbuildinfo.precommit 2>&1) + if [ $? -ne 0 ]; then + echo "ERROR: TypeScript issues found." echo "$tsc" - exit 1 # reject + exit_code=1 fi fi # scripts/precommit/i18n.sh -exit 0 +exit $exit_code