The pre-commit `types` hook never runs for a commit of only `.tsx` or `.jsx` files: its glob `"*.{js,ts, jsx, tsx}"` has spaces
Los mantenedores suelen responder en 5 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 88/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- git, typescript
- Área
- developer-experience
Línea de trabajo
El error está en el glob del comando types bajo pre-commit en lefthook.yml: "*.{js,ts, jsx, tsx}" tiene espacios sobrantes que hacen que las alternativas jsx y tsx no coincidan con nada. Elimina los espacios para que coincida con el glob de lint, y luego compruébalo añadiendo al stage solo un archivo .tsx con un error de tipos y confirmando que yarn tsc se ejecuta y bloquea el commit. Estará terminado cuando types se ejecute en commits que contengan solo .tsx y en commits que contengan solo .jsx.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Before submitting a new issue
- I tested using the latest version of the library, as the bug might be already fixed.
- I tested using a supported version of react native.
- I checked for possible duplicate issues, with possible answers.
Bug summary
lefthook.yml's pre-commit types command globs "*.{js,ts, jsx, tsx}". The spaces make two of the brace alternatives jsx and tsx, which no file name matches, so a commit that stages only .tsx or .jsx files skips yarn tsc, and a type error in it is committed. The lint command above it globs "*.{js,ts,jsx,tsx}" and runs.
pre-commit:
parallel: true
commands:
lint:
glob: "*.{js,ts,jsx,tsx}"
run: yarn eslint {staged_files}
types:
glob: "*.{js,ts, jsx, tsx}"
run: yarn tsc
Most of the repository's tests are .tsx files, so a commit of a test alone is the common case.
Library version
main at a37903f (0.0.0-nightly.a37903f)
Environment info
Windows 11 10.0.26300, Node 26.12.1, Yarn 4.9.2, lefthook 2.1.9 (the repository's dev dependency), Git for Windows.
No app or native build is involved: this is the repository's own pre-commit hook.
Steps to reproduce
- Clone
mainand install, which installs the lefthook hooks:git clone https://github.com/nativewind/react-native-css cd react-native-css yarn install - Add a
.tsxfile with a type error and commit it alone:printf 'export const count: number = "one";\n' > src/type-error.tsx git add src/type-error.tsx git commit -m "test: a .tsx file with a type error, committed alone" - Add any
.tsfile beside it and commit again:printf 'export const control = 1;\n' > src/control.ts git add src/control.ts git commit -m "test: a .ts file beside it"
The reproducer branch is main at a37903f with step 2's commit on it, which went in with types skipped.
Expected: types runs in step 2, as it does in step 3, and refuses the commit with the type error.
Actual: step 2 prints types (skip) no matching staged files and commits; step 3 runs types, which reports src/type-error.tsx(1,14): error TS2322 and refuses the commit.
Step 2's output on main at a37903f, Windows 11
╭──────────────────────────────────────╮
│ lefthook v2.1.9 hook: pre-commit │
╰──────────────────────────────────────╯
│ types (skip) no matching staged files
┃ lint ❯
────────────────────────────────────
summary: (done in 6.78 seconds)
✓ lint (6.62 seconds)
╭──────────────────────────────────────╮
│ lefthook v2.1.9 hook: commit-msg │
╰──────────────────────────────────────╯
┃ commitlint ❯
────────────────────────────────────
summary: (done in 1.86 seconds)
✓ commitlint (1.86 seconds)
[repro/554-types-hook-skips-tsx-commits 07d3993] test: a .tsx file with a type error, committed alone
1 file changed, 1 insertion(+)
create mode 100644 src/type-error.tsx
Step 3's output
╭──────────────────────────────────────╮
│ lefthook v2.1.9 hook: pre-commit │
╰──────────────────────────────────────╯
┃ lint ❯
┃ types ❯
src/type-error.tsx(1,14): error TS2322: Type 'string' is not assignable to type 'number'.
exit status 2
────────────────────────────────────
summary: (done in 7.96 seconds)
✓ lint (4.13 seconds)
✗ types (7.89 seconds)
Reproducible example repository
https://github.com/YevheniiKotyrlo/react-native-css/tree/repro/554-types-hook-skips-tsx-commits
- Lenguaje dominante
- TypeScript
- Estrellas
- 166
- Forks
- 45
- Merge medio
- 10 d 1 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nativewind/react-native-css
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
nativewind/react-native-css#549 · 2 comentarios ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nativewind/react-native-css#548 · 2 comentarios ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nativewind/react-native-css#545 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nativewind/react-native-css#544 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nativewind/react-native-css#543 ·
Los mantenedores suelen responder en 5 días
Todos los issues de nativewind/react-native-css
Issues similares
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/playwright#43875 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
calagopus/panel#285 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 88/100
adobe/react-spectrum#10909 ·
Los mantenedores suelen responder en 1 día
-
Keybind conflict with "Tileset"Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Run the dependency drift checkPosiblemente ocupada @spaceninja la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
cloudfour/lighthouse-parade#449 ·
Los mantenedores suelen responder en 1 día