⚡️ 优化 ESLint harness 性能并统一诊断断言 (Linter.verify and ruleIdsAt) - #1759
Open
cyfung1031 wants to merge 4 commits into
Open
cyfung1031 wants to merge 4 commits into
cyfung1031 wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
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— 均通过。Screenshots / 截图
N/A — 仅测试改动。