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

Đang mở
#427 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
testing-qa

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
0
Fork
0
Merge trung bình
38 phút
Pull request đã merge (30 ngày)
96

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Rule-Of-Code/RoC

Tất cả issue của Rule-Of-Code/RoC

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.