Skip to content

Commit fb548d4

Browse files
committed
fix(hooks): treat untracked JavaScript and JSON as type-check inputs too
1 parent ea38d3c commit fb548d4

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎.husky/pre-push‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ done
3737
[ "$pushes_head" = true ] || exit 0
3838

3939
# Lint and type-check read the working tree, so they judge the pushed commit only when nothing they
40-
# read differs from it: no uncommitted change to a tracked file and no untracked TypeScript the
41-
# type-check would compile. Otherwise they could fail a sound commit or pass a broken one.
42-
if ! git diff --quiet HEAD ||
43-
[ -n "$(git ls-files --others --exclude-standard -- '*.ts' '*.tsx' '*.mts' '*.cts')" ]; then
44-
echo "pre-push: uncommitted changes or untracked TypeScript; leaving lint, type-check and generated artifacts to CI"
40+
# read differs from it: no uncommitted change to a tracked file and no untracked file the type-check
41+
# could read (TypeScript, JavaScript under `allowJs`, JSON under `resolveJsonModule`). Otherwise
42+
# they could fail a sound commit or pass a broken one.
43+
if ! git diff --quiet HEAD || [ -n "$(git ls-files --others --exclude-standard -- \
44+
'*.ts' '*.tsx' '*.mts' '*.cts' '*.js' '*.jsx' '*.mjs' '*.cjs' '*.json')" ]; then
45+
echo "pre-push: uncommitted changes or untracked source files; leaving lint, type-check and generated artifacts to CI"
4546
exit 0
4647
fi
4748

0 commit comments

Comments
 (0)