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
|
||||
*.aab
|
||||
*.ipa
|
||||
.tsbuildinfo.precommit
|
||||
|
||||
*/**/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"
|
||||
fi
|
||||
|
||||
rm -rf .tsbuildinfo.precommit
|
||||
rm -rf ios/Pods
|
||||
rm -rf node_modules
|
||||
rm -rf dist
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue