without a loadable typescript, CodeText.codeOnly silently falls back to a regex and an error-severity law changes its verdict

Abierto
#427 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
testing-qa

Línea de trabajo

Start with src/utils/code-text.ts around lines 58–64 and inspect how codeOnly handles a missing TypeScript parser; then check the laws that consume it and tsx-source.ts around line 48. Reproduce the reported verdict difference with and without TypeScript installed. Done when missing parser availability no longer silently changes an error-severity law’s verdict, and the not-read message correctly describes .ts files.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Found in the 8.0.0 self-audit triage: RoC 7.29.1 (npm, 5fc54afe) on a clean clone of develop at 2d2fa9a, with typescript resolvable (verdict compliance, 0 failed / 46 warnings). The bucket method and per-law tables are kept by QA; counts are from that run.

What happens

CodeText.codeOnly (src/utils/code-text.ts:58-64) uses the TypeScript parser to blank strings and comments, and silently falls back to stripCommentsAndStrings when no typescript can be loaded: if (!ts) return this.stripCommentsAndStrings(content);. Its own comment says the regex "loses its place on nested quotes … a test file that keeps fixtures as source strings is exactly that shape".

Same clone, same RoC 7.29.1, only the presence of typescript differs:

no typescript typescript resolvable
verdict / exit failed / 1 compliance / 0
failed / warnings 2 / 48 0 / 46
Test Isolation Enforcement (error) FAIL, 2 (it.only, localStorage, fetch( inside fixture strings) pass
Test Documentation Requirements 167 unclear titles (fixtures) 1
Test Data Management 4 3

Laws that load typescript themselves say so honestly ("could not load the 'typescript' package … NOT read"), but the regex-fallback laws give a different, stricter verdict with no note. typescript is not a dependency of ruleofcode, so the verdict of an error-severity law depends on whether the audited project happens to have typescript installed.

Related: the not-read message says ".tsx/.jsx files were NOT read" for plain .ts files (tsx-source.ts:48); Independent Awaits reports "read 0 of 78 files" as an ordinary failure, not judged nothing.

Suggested direction

Either make typescript a dependency of ruleofcode (the parser path then always exists), or make codeOnly report not-read instead of falling back, so a law that could not separate code from text says so (partial) instead of judging fixtures. Fix the message wording for .ts.

Lenguaje dominante
TypeScript
Estrellas
0
Forks
0
Merge medio
38 min
PR fusionados (30 d)
96

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Rule-Of-Code/RoC

Todos los issues de Rule-Of-Code/RoC

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.