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

未关闭
#427 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
testing-qa

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
0
派生
0
平均合并
38 分钟
30 天内合并 PR
96

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Rule-Of-Code/RoC 的其他 Issue

查看 Rule-Of-Code/RoC 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。