Skip to content

feat(rimraf): add fs.rm migration recipe - #486

Open
Herrtian wants to merge 8 commits into
nodejs:mainfrom
Herrtian:rimraf-to-fs-rm-472
Open

Herrtian wants to merge 8 commits into
nodejs:mainfrom
Herrtian:rimraf-to-fs-rm-472

Conversation

@Herrtian

@Herrtian Herrtian commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #472.\n\n## Summary\n- add a rimraf-to-fs-rm recipe for literal rimraf deletes\n- handle v3 callback calls, v4/v5 promise calls, v5 sync calls, aliases, and sync glob expansion\n- document manual-review cases for runtime-specific rimraf behavior\n\n## Validation\n- npm.cmd run test --workspace @nodejs/rimraf-to-fs-rm\n- npm.cmd run type-check\n- npm.cmd run lint

@AugustinMauroy

Copy link
Copy Markdown
Member

thanks for being volunteering but you have 4 opened PRs we didn't have a lot of maintainer on this initiative so plz don't open any other pr.

@AugustinMauroy AugustinMauroy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • give name to tests cases
  • add remove dep step but before calling the function analyse the json ast to know if rimraf isn't used as cli
  • add jsdocs to workflow

@Herrtian

Herrtian commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, understood. I won't open more PRs and will focus on the existing ones. I pushed the requested updates in the latest commit.

Comment thread recipes/rimraf-to-fs-rm/src/workflow.ts Resolved
Comment thread recipes/rimraf-to-fs-rm/src/workflow.ts Resolved
Comment thread recipes/rimraf-to-fs-rm/src/workflow.ts Resolved
Comment thread recipes/rimraf-to-fs-rm/README.md Resolved
@AugustinMauroy AugustinMauroy added await:author Reviewer has requested something from the author ⚠️ fully-AI-generated labels Jun 7, 2026
Comment thread recipes/rimraf-to-fs-rm/src/workflow.ts Outdated
Comment on lines +221 to +224
const hasCallEdits = edits.length > 0;
if (!hasCallEdits) {
return null;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const hasCallEdits = edits.length > 0;
if (!hasCallEdits) {
return null;
}
if (!edits.length ) return null;

@AugustinMauroy AugustinMauroy added await:reviewer Author has responded and needs action from the reviewer and removed await:author Reviewer has requested something from the author labels Jun 12, 2026
Comment on lines +20 to +25
/**
* Escapes a binding name so it can be used safely in an ast-grep regex.
*/
const escapeRegex = (value: string) =>
value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RegExp.escape?

Comment on lines +26 to +27
const getLineEnding = (source: string) =>
source.includes('\r\n') ? '\r\n' : '\n';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO just use a \n, the users' formatter will handle it from there

*/
const parseImportBindings = (source: string): Binding[] => {
const bindings = parseNamedBindings(source);
const defaultMatch = source.match(/^import\s+([^,{]+?)(?:\s*,|\s+from\s+)/);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about dynamic imports?

Comment on lines +122 to +125
/**
* Builds the recursive rm options that match rimraf's common force behavior.
*/
const buildRmOptions = () => '{ recursive: true, force: true }';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis can be a constant

@AugustinMauroy

Copy link
Copy Markdown
Member

@Herrtian any news ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

await:reviewer Author has responded and needs action from the reviewer ⚠️ fully-AI-generated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spec: Rimraf to Native fs.rm() Comparison Suite

3 participants