Skip to content

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

Open
cyfung1031 wants to merge 4 commits into
scriptscat:mainfrom
cyfung1031:test/optimize-eslint-harness-shadowing
Open

cyfung1031 wants to merge 4 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.mjspnpm 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
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.

1 participant