Skip to content

⚡️ 优化 ESLint harness 性能并统一诊断断言 (Linter.verify and ruleIdsAt) - #1759

Merged
CodFrm merged 6 commits into
scriptscat:mainfrom
cyfung1031:test/optimize-eslint-harness-shadowing
Sep 28, 2026
Merged

CodFrm merged 6 commits into
scriptscat:mainfrom
cyfung1031:test/optimize-eslint-harness-shadowing

Conversation

@cyfung1031

@cyfung1031 cyfung1031 commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Checklist / 检查清单

  • Fixes mentioned issues / 修复已提及的问题
  • Code reviewed by human / 代码通过人工检查
  • Changes tested / 已完成测试

N/A — 本 PR 未关联 issue。

Description / 描述

CI 曾观测到名称遮蔽用例耗时 367 ms,超过现有 340 ms 超时;该用例原先对同一虚拟文件执行三次 Linter.verify()。现在同文件名下的多段代码夹具共用一次 lint,整个 harness 减少 16 次 ruleIdsAt() 调用。不同文件名仍分别 lint,以保留各自的 ESLint 配置作用域;340 ms 超时保持不变。

测试辅助函数统一以 { code, filename } 接收具名输入。新增 ruleCountAt({ code, filename, ruleId }) 返回指定规则的诊断数量,使拦截、放行和重复诊断用例都直接断言预期数量。

验证

  • pnpm exec vitest run eslint-rules/harness.test.mjs — 37/37 通过。
  • pnpm exec vitest run eslint-rules/harness.test.mjs --coverage — 37/37 通过。
  • pnpm exec eslint eslint-rules/harness.test.mjs、pnpm exec prettier --check eslint-rules/harness.test.mjs 和提交钩子的 tsc --noEmit — 均通过。
  • 名称遮蔽用例的本地测量:首次合并前 84 ms,之后为 45 ms 和 40 ms。
  • 此前一次详细覆盖率运行出现 6 个 340 ms 超时(包括未改动的单次 lint 用例);本次标准覆盖率运行通过。

Screenshots / 截图

N/A — 仅测试改动。

@cyfung1031 cyfung1031 changed the title test: speed up waitFor interaction harness ⚡️ 优化 ESLint harness 性能并统一诊断断言 Sep 20, 2026
@cyfung1031 cyfung1031 changed the title ⚡️ 优化 ESLint harness 性能并统一诊断断言 ⚡️ 优化 ESLint harness 性能并统一诊断断言 (Linter.verify and ruleIdsAt) Sep 21, 2026
@cyfung1031 cyfung1031 added the P2 🐌 非重要也不紧急的内容 label Sep 22, 2026
合并夹具时顶层 const Array 遮蔽了下方带 eslint-disable 注释的 Array.from,导致删掉豁免注释用例仍通过;把遮蔽用例移入独立函数作用域,两个分支各自可被变异检出。同时删去复述代码的注释。
@CodFrm
CodFrm merged commit 120039b into scriptscat:main Sep 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 🐌 非重要也不紧急的内容

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants