-
-
Notifications
You must be signed in to change notification settings - Fork 20
feat(migrate-legacy-buffer-atob-btoa
): introduce
#206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(migrate-legacy-buffer-atob-btoa
): introduce
#206
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice! But my advice is to start writing test commit them on local then build the codemod and then push everything
"author": "nekojanai (Jana)", | ||
"license": "MIT", | ||
"homepage": "https://github.com/nodejs/userland-migrations/blob/main/recipes/buffer-atob-btoa/README.md", | ||
"dependencies": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe need to add jssg types as devdep to have typing on codemod context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nekojanai you have to add it for strictness
23a2fcf
to
2c2fee2
Compare
2c2fee2
to
f6f823e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test/feature:
- dynamic import
- esm import
@AugustinMauroy Could you provide examples for dynamic and esm imports to test against? |
ESM importInput/before: import buffer from "node:buffer";
// do stuff Dynamic importconst buffer = await import("node:buffer");
// do stuff Don't worry it's shouldn't complicated because we have serval utilities for that |
Should be gtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now, Thank you!
} | ||
]; | ||
|
||
const statements = [...getNodeRequireCalls(root, 'buffer'), ...getNodeImportStatements(root, 'buffer')]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const statements = [...getNodeRequireCalls(root, 'buffer'), ...getNodeImportStatements(root, 'buffer')]; | |
const statements = [ | |
...getNodeRequireCalls(root, 'buffer'), | |
...getNodeImportStatements(root, 'buffer') | |
]; |
|
||
export default function transform(root: SgRoot<Js>): string | null { | ||
const rootNode = root.root(); | ||
const bindingStatementFnTuples: [string, SgNode<Js, Kinds<Js>>, (arg: string) => string][] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const bindingStatementFnTuples: [string, SgNode<Js, Kinds<Js>>, (arg: string) => string][] = []; | |
const bindingStatementFnTuples: [string, SgNode<Js>, (arg: string) => string][] = []; |
this type can be simplified
} | ||
}); | ||
|
||
const otherCalls = rootNode.findAll({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you remove that it's should work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do I not need to check for any other calls to an import before deleting it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh make sense maybe add comment on top of this query
linesToRemove.push(statement.range()); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!edits.lenght) return null | |
closes #98