Skip to content

fix(build): restore the supported validation toolchain - #32

Merged
setube merged 2 commits into
setube:mainfrom
Jacobinwwey:fix/validation-toolchain
Oct 17, 2026
Merged

setube merged 2 commits into
setube:mainfrom
Jacobinwwey:fix/validation-toolchain

Conversation

@Jacobinwwey

@Jacobinwwey Jacobinwwey commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

1. Context & Motivation (Context)

  • Issue: No linked issue; the current validation commands cannot run cleanly with the declared compiler.
  • Problem: TypeScript 7 no longer provides the JavaScript compiler API expected by the installed vue-tsc toolchain and the formatter tests; typescript-eslint declares support below 6.1. Existing TS import suffixes, unused bindings and a CommonJS translation script inside an ESM package expose further validation blockers.
  • Trade-offs: Pin TypeScript to ~5.9.3, compatible with the current tooling, instead of migrating compiler consumers in this repair. Formatter tests use the existing esbuild dependency. No new dependency or detection hot-path change.

2. Implementation Details (Implementation)

  • Update the Bun lockfile and enable the TS import suffixes already present in the Vite configuration.
  • Remove only unused imports and prefix unused API parameters without changing argument positions.
  • Make translation generation ESM-compatible, resolve output relative to the module and write once after all entries are assembled. Regression coverage checks both the first and last translation groups.
  • Note: The independent PageSupport.reasonCode defect remains outside this diff. Merge fix(popup): return localization keys for unsupported pages #30 as well to make the complete typecheck green.

3. Testing Strategies (Validation)

  • bun run test:unit: 27/27 pass on this branch, including existing formatter regressions and the new translation-generator test.
  • bun run lint passes on this branch.
  • Translation generation runs from a different working directory and writes beside its module in an isolated fixture.
  • With the separate page-support fix applied, bun run typecheck completes vue-tsc and the production extension build; the combined fork has 36 passing unit tests and the SDK candidate passed 13 real-Chrome integration tests.
  • Standalone typecheck now reaches the three existing TS2339 reasonCode errors addressed by PR 30. It is not reported as passing independently.

Pin TypeScript to the compiler API supported by vue-tsc and typescript-eslint. Use the existing esbuild dependency for formatter fixtures, permit the existing TS import suffixes, and remove compilation/lint blockers. Run translation generation as ESM with module-relative output and cover invocation from another working directory. The independent PageSupport.reasonCode compile errors remain for the separate page-support fix.

Signed-off-by: aliyun1121003339 <jacob.hxx.cn@outlook.com>
@sourcery-ai

sourcery-ai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

评审者指南

此 PR 通过将 TypeScript 固定到 5.9 版本、在格式化工具测试中移除对 TypeScript 编译器 API 的依赖、启用现有的导入约定,并修复 ESM/可移植翻译生成,恢复了受支持的验证工具链。此外,它还清理了未使用的绑定并添加了回归测试;独立的类型检查仍依赖 PR 30 中单独修复的 PageSupport.reasonCode。

可移植 ESM 翻译生成时序图

sequenceDiagram
    participant Test as Translation test
    participant Generator as gen_trans.js
    participant FS as File system

    Test->>Generator: run from another working directory
    Generator->>Generator: import fs from node:fs
    Generator->>FS: resolve evidence_translations.json via import.meta.url
    Generator->>FS: write generated translations
    FS-->>Test: output beside generator module
Loading

文件级变更

变更 详情 文件
恢复与 vue-tsc、typescript-eslint 和验证脚本兼容的 TypeScript/工具链组合。
  • 将 TypeScript 固定到 5.9 版本系列,并更新 Bun 锁定文件。
  • 启用现有 Vite 配置所需的 TypeScript 导入后缀。
  • 将格式化工具测试中对 TypeScript 编译器 API 的使用替换为 esbuild 转译。
package.json
bun.lock
tsconfig.json
tests/format-tech-stack.test.mjs
使翻译生成过程具备可移植性,并兼容软件包的 ESM 运行时。
  • 将生成器从 CommonJS 导入转换为 ESM 导入。
  • 将翻译输出解析到生成器模块所在目录,而不再使用特定于某台机器的绝对路径。
  • 添加一项隔离测试,覆盖从其他工作目录执行以及输出位置。
src/i18n/gen_trans.js
tests/translation-generation.test.mjs
移除会阻碍验证的未使用绑定,同时不更改运行时 API。
  • 删除未使用的 UI 导入。
  • 为有意未使用的翻译参数添加前缀,同时保留其参数位置。
src/ui/popup/Popup.vue
src/ui/settings/Settings.vue
src/utils/build-issue-url.ts

提示与命令

与 Sourcery 互动

  • 触发新的评审: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 根据评审评论创建 GitHub issue: 回复评审评论,请 Sourcery 根据该评论创建 issue。你也可以在评审评论中回复 @sourcery-ai issue,根据该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中你希望放置摘要的位置写入 @sourcery-ai summary,即可随时在那里生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,随时(重新)生成摘要。
  • 生成评审者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成评审者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 忽略所有 Sourcery 评审: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 评审。如果你想从头开始进行新的评审,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的评审!

自定义你的体验

访问你的控制面板以便:

  • 启用或禁用评审功能,例如 Sourcery 生成的拉取请求摘要、评审者指南等。
  • 更改评审语言。
  • 添加、移除或编辑自定义评审说明。
  • 调整其他评审设置。

获取帮助

Original review guide in English

Reviewer's Guide

This PR restores the supported validation toolchain by pinning TypeScript to 5.9, removing reliance on the TypeScript compiler API in formatter tests, enabling existing import conventions, and fixing ESM/portable translation generation. It also cleans up unused bindings and adds regression coverage; standalone typecheck still depends on the separate PageSupport.reasonCode fix in PR 30.

Sequence diagram for portable ESM translation generation

sequenceDiagram
    participant Test as Translation test
    participant Generator as gen_trans.js
    participant FS as File system

    Test->>Generator: run from another working directory
    Generator->>Generator: import fs from node:fs
    Generator->>FS: resolve evidence_translations.json via import.meta.url
    Generator->>FS: write generated translations
    FS-->>Test: output beside generator module
Loading

File-Level Changes

Change Details Files
Restore a TypeScript/tooling combination compatible with vue-tsc, typescript-eslint, and validation scripts.
  • Pin TypeScript to the 5.9 release line and update the Bun lockfile.
  • Enable TypeScript import suffixes required by the existing Vite configuration.
  • Replace the formatter test’s TypeScript compiler API usage with esbuild transpilation.
package.json
bun.lock
tsconfig.json
tests/format-tech-stack.test.mjs
Make translation generation portable and compatible with the package’s ESM runtime.
  • Convert the generator from CommonJS to ESM imports.
  • Resolve the translation output beside the generator module instead of using a machine-specific absolute path.
  • Add an isolated test covering execution from another working directory and output placement.
src/i18n/gen_trans.js
tests/translation-generation.test.mjs
Remove validation-blocking unused bindings without changing runtime APIs.
  • Delete unused UI imports.
  • Prefix intentionally unused translation parameters while preserving their argument positions.
src/ui/popup/Popup.vue
src/ui/settings/Settings.vue
src/utils/build-issue-url.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好——我发现了 1 个问题

给 AI 代理的提示
请处理这次代码审查中的评论:

## 单条评论

### 评论 1
<location path="src/i18n/gen_trans.js" line_range="1" />
<code_context>
-const fs = require('fs')
-const f = 'D:/压缩/tech-detector-extension/src/i18n/evidence_translations.json'
+import fs from 'node:fs'
+const f = new URL('./evidence_translations.json', import.meta.url)
 const d = {}
</code_context>
<issue_to_address>
**重新生成会丢失大部分翻译**

运行翻译生成器时,`fs.writeFileSync` 会在剩余的 `Object.assign` 调用执行之前写入 `d`,因此运行生成器会将翻译文件替换为仅包含初始条目的内容;最终写入虽然发生在所有条目都添加之后,但之前的写入已经截断了文件。

移除提前执行的写入,并且只在所有翻译条目都赋值完成后写入完整的 `d`。
</issue_to_address>

Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享 ✨
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/i18n/gen_trans.js" line_range="1" />
<code_context>
-const fs = require('fs')
-const f = 'D:/压缩/tech-detector-extension/src/i18n/evidence_translations.json'
+import fs from 'node:fs'
+const f = new URL('./evidence_translations.json', import.meta.url)
 const d = {}
</code_context>
<issue_to_address>
**Regeneration drops most translations**

When the translation generator is run, `fs.writeFileSync` writes `d` before the remaining `Object.assign` calls run, so invoking the generator replaces the translation file with only the initial entries; the final write occurs after all entries have been added, but the earlier write has already truncated the file.

Remove the early write and write the completed `d` only after all translation entries have been assigned.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/i18n/gen_trans.js Resolved
Signed-off-by: aliyun1121003339 <jacob.hxx.cn@outlook.com>
@setube
setube merged commit 58cf3c9 into setube:main Oct 17, 2026
1 check passed
setube added a commit that referenced this pull request Oct 21, 2026
收录 Vue Devtools 误报修复(#34)、PR #30/#31/#32 修复和 #33 SDK,page-support.ts 按 Prettier 换行。

将版本号提升到 1.3.91。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants