Repository navigation
chore: compare lint guard JS plugins regardless of their order - #5249
Conversation
oxlint prints jsPlugins in an order that depends on the checkout directory, so the guard reported "jsPlugins changed" and failed pnpm lint in some checkouts without any config change. Compare JS plugins as members, like plugins: a removed plugin is reported as weakened and an added one as changed, while a different order is not reported. Record them sorted so that --update writes the same snapshot in every checkout, and rewrite the snapshot in that order.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
Keep a per-step next-block cursor so an open step's content parts append straight to the turn and only out-of-order rewrites fall back to upsert (MoonshotAI#5344); a step with no items seeds the cursor and step.end drops it. Compare and diff jsPlugins as sets so lint-guard configs are order insensitive and a removed plugin reads as weakened (MoonshotAI#5249). Ledger: 5015 equivalent.
Requirement or Bug
在有的检出目录里,
pnpm lint会在 guards 这一步失败,报changed: jsPlugins changed,但.oxlintrc.json和快照都没改。仓库要求结束改动前pnpm lint必须以 0 退出,所以在这些目录里工作的人和 agent 都会被挡住,还容易误用--update改写快照来绕过。这个 PR 之后,guards 的结果不再取决于在哪个目录里运行。Bug Reproduction Steps
pnpm exec oxlint --type-aware --print-config。两边打印出的jsPlugins顺序不同;在同一个目录里多跑几次,结果一致。node scripts/checks/guards.mjs:报jsPlugins changed,以 1 退出。Root Cause
guards 把
jsPlugins当成普通字段,用 JSON 字符串整体比较,数组顺序一变就算改动;--update也照 oxlint 打印的顺序写快照。但 oxlint 打印jsPlugins的顺序随检出目录变化,并不一定是配置里写的顺序,所以快照只在和生成它的目录顺序相同的地方才能通过。这是根本修复:比较和写快照都不再依赖这个顺序。
Code Changes
diffConfigs把jsPlugins和plugins一样按成员比较:只是顺序不同不报;删掉一个插件报 weakened,新增一个报 changed。normalizeConfig:读取生效配置时先给jsPlugins排序,所以--update在任何目录写出的快照都一样。它是readEffectiveConfig里不调用 oxlint 的那部分,拆出来是为了能写单元测试。Behavior Changes and Affected Users
changed: jsPlugins changed,lint 失败changed: jsPlugins changedweakened: JS plugin removed: <路径>,新增报changed: JS plugin added: <路径>,lint 仍然失败--update写出的快照测试:
scripts/checks/guards.test.mjs新增 3 条:只换顺序时不报差异;增删插件时的报法;normalizeConfig的结果不随打印顺序变化。前两条在修复前失败,报的就是jsPlugins changed;第三条在去掉排序后失败。验证(macOS)
node --test 'scripts/checks/*.test.mjs':60 条全部通过。pnpm lint:在顺序和原快照相反的检出目录里以 0 退出,修复前在 guards 这一步失败。--update写出的快照和这里逐字节相同。只改仓库脚本、测试和快照,不需要 changeset。
Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.