fix(test): close remove-tree lint AST false positives and negatives - #825
ScriptedAlchemy wants to merge 1 commit into
Conversation
Recognize shorthand maxRetries, shadowed local rm, named promises rebinds from fs/node:fs, and assertion/paren/satisfies option wrappers. Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aeb8c3f1c3
ℹ️ 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".
| if (ts.isSourceFile(current) || ts.isBlock(current) || ts.isModuleBlock(current)) { | ||
| const shadowed = current.statements.some((statement) => { | ||
| if (ts.isSourceFile(current) && ts.isImportDeclaration(statement)) return false; | ||
| return statementDeclares(statement, name); | ||
| }); |
There was a problem hiding this comment.
Handle loop bindings when resolving shadowed imports
When a newly recognized promises alias is shadowed by a loop binding—for example, import { promises as fs } from 'node:fs'; for (const fs of mockFilesystems) await fs.rm(root, { recursive: true })—this scan never sees the ForOfStatement declaration because statementDeclares only accepts variable statements, functions, and classes. The loop-local call is therefore attributed to Node and produces a lint false positive; include loop initializer bindings and analogous lexical declaration sites in shadow resolution.
Useful? React with 👍 / 👎.
Codex Review SummaryThis 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. |
After #823,
scripts/check-test-remove-tree.mjsstill missed four parser-backed cases Codex flagged.Fixes
maxRetries:{ recursive: true, maxRetries }is accepted (ShorthandPropertyAssignment).rm: a later local binding afterimport { rm } from 'node:fs'is not treated as Node-bound.promisesrebind:import { promises as fs } from 'node:fs'(or'fs') is a namespace /.rmcarrier.AsExpression,ParenthesizedExpression, andSatisfiesExpressionso{ recursive: true } as constis still seen as recursive.The gate stays typescript-5 AST-backed. No regex / text masking.
Tests
packages/agent-bundle/tests/check-test-remove-tree.test.tsnow covers both directions:maxRetriesis OKrmis ignored; unshadowed Nodermstill failsimport { promises as fs } from 'node:fs'+ recursivermwithoutmaxRetriesfails; withmaxRetriespasses{ recursive: true } as constwithoutmaxRetriesfails; withmaxRetriespassessatisfieswrappers without retries still failExisting removeTree helper exemption and good-path cases stay in the file.
Notes
tests/**only; no changeset (publishablechangedFilePatternsexemptstests/**).Verification
Ran after
pnpm build(rstest dist-freshness):