perf(linter/jest-vitest/valid-expect): avoid extra sorting work#23884
perf(linter/jest-vitest/valid-expect): avoid extra sorting work#23884camc314 wants to merge 1 commit into
Conversation
Merge activity
|
37d29d3 to
fece223
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37d29d3fea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| possible_jest_nodes.sort_unstable_by_key(|node| node.node.id()); | ||
| // Order only matters for deterministic diagnostics; node id order is enough | ||
| // without an extra sort if we collect in reference walk order (stable enough). | ||
| let possible_jest_nodes = collect_possible_jest_call_node(ctx); |
There was a problem hiding this comment.
Preserve source order before building per-function fixes
When collection order is import/global reference order rather than source order, fixed_function_expression can be set by a later assertion before an earlier one is visited. For example with import { expect as e } from 'vitest'; test('x', () => { expect(p).resolves.toBe(1); e(q).resolves.toBe(2); }), the imported alias is visited first, so its multifix inserts async and spans from the function start to the later call; the earlier global expect then only gets an await fix, but Fixer::fix sorts fixes by span and skips that earlier fix as overlapping. The result of applying suggestions is that the first assertion is still unawaited, which the previous node-id sort avoided.
Useful? React with 👍 / 👎.
Split from #23829.
Ports the shared valid-expect collection optimization from #23829 to avoid extra sorting work.
Co-authored-by: Yagiz Nizipli yagiz@nizipli.com