Skip to content

fix(i18n): 删掉九份 i18n-extract 配置里未声明的 name: - #4803

Merged
os-zhuang merged 2 commits into
mainfrom
claude/issue-4736-i18n-extract-stack-name
Aug 3, 2026
Merged

fix(i18n): 删掉九份 i18n-extract 配置里未声明的 name:#4803
os-zhuang merged 2 commits into
mainfrom
claude/issue-4736-i18n-extract-stack-name

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Fixes #4736

问题

九份 scripts/i18n-extract.config.ts 都在 defineStack({ … }) 顶层写了一个 name:ObjectStackDefinitionSchema 并未声明这个键,parse 时值被直接丢弃,#4167 的 unknown-stack-key lint 于是每个包都报一次 —— 出现在一次全绿pnpm check:i18n 运行里:

defineStack: stack.name: 'name' is not a declared stack key, so its value is dropped at load — did you mean 'pages'?

lint 是对的,配置是错的。绿色运行里稳定出现的 warning 会训练人(和 agent)把 warning 读成噪音,这本身就是成本;而且同一个错被拷贝了九份,说明后来者是照着第一份抄的。

处置:方案 A(删掉九处 name:),不走 B

按 issue 里 PM 的裁定取 A。核实过前提确实成立 —— 没有任何东西读过 stack 顶层的 name:

  • ObjectStackDefinitionSchema 的顶层键里没有 name(manifest / objects / translations / i18n / … 均在,name 不在);
  • 这九个文件 export default defineStack({ … }),导出的是 parse 之后的结果,name 在这一步就已经没了;
  • os i18n extract 通过 loadConfig 拿到的正是那个 default 导出,它读 i18n / objects / apps,从头到尾没有碰过 name;
  • 全仓只有两个消费者引用这些配置(package.jsoni18n:extractscripts/check-i18n-bundles.mjs),都走同一条 os i18n extract 路径。

所以 B(把 name 走 spec 正路声明成 authorable key)是为了迁就九份互相拷贝的笔误去扩大公开契约面,以后还要一直养着它(生成物、文档、退役流程)。按 Prime Directive #12,修在 producer 一侧,而不是让 spec 或 lint 去容忍。

本 PR 不动 lint 规则、不动 defineStack 的 schema、packages/spec/** 零改动。 改动面 = 九个 scripts/i18n-extract.config.ts + 一份 changeset,共 10 行删除。

提取结果不变 —— 实测,不是假设

改动前 check:i18n 九个包全部 in sync(共 40 个 bundle)。删掉 name: 之后:

  1. pnpm check:i18n 仍然九个包全部 in sync,bundle 数一致,且那条 warning 不再出现;
  2. 进一步跑了一次全量重生成 node scripts/check-i18n-bundles.mjs --write —— 40 个 bundle 全部重写后 git statussrc/translations/** 干净,即提取产物逐字节一致

合并 origin/main(带入了 platform-objects/srcobjectql/src 的改动)后重新构建并复跑 check:i18n,依旧全绿且无 warning。

关于测试

没有新增单测,理由:改动是九个构建期夹具里的纯删除,scripts/ 不在任何包的 files 里(只发布 dist),也不在各包 tsconfig 的 include 里,没有自然的单测落点。真正执行这些文件的是 check:i18n 门禁本身(它通过 bundleRequire 实打实加载并运行每一份配置),所以证据用它的实测输出:见上。

顺带一提:能防住"第十份照抄"的最廉价办法是把这条 lint 升级为 check:i18n 的硬失败 —— 但那会改变 gate 行为,属于另一个决定,按 issue 的范围约束不在本 PR 实现,只在报告里提出建议。

验证

命令 结果
pnpm check:i18n(改动前) OK,9 包全 in sync,每包一条 warning
pnpm check:i18n(改动后 / 合并 main 后) OK,9 包全 in sync,无 warning
node scripts/check-i18n-bundles.mjs --write 40 个 bundle 重生成后零 diff
turbo run typecheck(九个受影响包) 22 tasks successful
turbo run test(九个受影响包) 23 tasks successful,116 test files 全绿

🤖 Generated with Claude Code

https://claude.ai/code/session_015Br2xsJsczFsTR9bvbh2Ny


Generated by Claude Code

claude added 2 commits August 3, 2026 07:40
… configs

All nine `scripts/i18n-extract.config.ts` opened their `defineStack({ … })`
with a top-level `name:` that `ObjectStackDefinitionSchema` does not declare.
The parse dropped the value at load and the #4167 unknown-stack-key lint
reported it once per package on every `pnpm check:i18n` run — a warning that
appeared in an otherwise fully green run, which is exactly how a team learns
to read warnings as noise.

The lint was correct; the configs were not. Nothing has ever read a stack's
top-level `name`: `os i18n extract` is handed the *parsed* `defineStack`
result, from which the key is already gone before the extractor starts. So
the fix belongs at the producer (delete the nine keys), not in `packages/spec`
as a new authorable key invented to accommodate one typo copied nine times
(Prime Directive #12 — fix the metadata, not the runtime).

Extraction output is unchanged and verified, not assumed: after the deletion
`node scripts/check-i18n-bundles.mjs --write` regenerates all 40 bundles
across the nine packages byte-identically (`git status` clean for every
`src/translations/**`), and `pnpm check:i18n` stays green — now silent.

Fixes #4736

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Br2xsJsczFsTR9bvbh2Ny
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 3, 2026 7:46am

Request Review

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

No hand-written docs reference the 0 changed package(s). ✅

@os-zhuang
os-zhuang marked this pull request as ready for review August 3, 2026 07:55
@os-zhuang
os-zhuang added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit ffab803 Aug 3, 2026
21 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-4736-i18n-extract-stack-name branch August 3, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

All nine i18n-extract configs author name: on defineStack — a key the lint drops at load, warning on every check:i18n run

2 participants