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
This commit is contained in:
parent
bb2321da26
commit
881342cb5f
4 changed files with 27 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -10,6 +10,7 @@ env.d.ts
|
||||||
*.apk
|
*.apk
|
||||||
*.aab
|
*.aab
|
||||||
*.ipa
|
*.ipa
|
||||||
|
.tsbuildinfo.precommit
|
||||||
|
|
||||||
*/**/compass-icons.ttf
|
*/**/compass-icons.ttf
|
||||||
|
|
||||||
|
|
|
||||||
15
eslint.precommit.config.mjs
Normal file
15
eslint.precommit.config.mjs
Normal file
|
|
@ -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',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
@ -8,6 +8,7 @@ if command -v watchman &> /dev/null; then
|
||||||
watchman watch-del . 2>/dev/null || echo "No watch found for this directory"
|
watchman watch-del . 2>/dev/null || echo "No watch found for this directory"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rm -rf .tsbuildinfo.precommit
|
||||||
rm -rf ios/Pods
|
rm -rf ios/Pods
|
||||||
rm -rf node_modules
|
rm -rf node_modules
|
||||||
rm -rf dist
|
rm -rf dist
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
jsfiles=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.js$|\.ts$|\.tsx$')
|
jsfiles=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.js$|\.ts$|\.tsx$')
|
||||||
|
exit_code=0
|
||||||
|
|
||||||
if [ -z "jsfiles" ]; then
|
if [ -z "jsfiles" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -10,23 +11,24 @@ if [ -n "$jsfiles" ]; then
|
||||||
echo "Checking lint for:"
|
echo "Checking lint for:"
|
||||||
for js in $jsfiles; do
|
for js in $jsfiles; do
|
||||||
echo "$js"
|
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
|
if [ -n "$e" ]; then
|
||||||
echo "ERROR: Check eslint hints."
|
echo "ERROR: Check eslint hints."
|
||||||
echo "$e"
|
echo "$e"
|
||||||
exit 1 # reject
|
exit_code=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Checking for TSC"
|
echo "Checking for TSC (fast incremental check)"
|
||||||
tsc=$(node_modules/.bin/tsc --noEmit)
|
# Use incremental TypeScript checking - much faster on subsequent runs
|
||||||
if [ -n "$tsc" ]; then
|
tsc=$(node_modules/.bin/tsc --noEmit --incremental --tsBuildInfoFile .tsbuildinfo.precommit 2>&1)
|
||||||
echo "ERROR: Check TSC hints."
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR: TypeScript issues found."
|
||||||
echo "$tsc"
|
echo "$tsc"
|
||||||
exit 1 # reject
|
exit_code=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# scripts/precommit/i18n.sh
|
# scripts/precommit/i18n.sh
|
||||||
|
|
||||||
exit 0
|
exit $exit_code
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue