Skip to content

Addition of custom collection functions for importDeclarations/Specifiers#617

Merged
Daniel15 merged 1 commit intofacebook:mainfrom
danieldelcore:import-collection-utils
Aug 2, 2024
Merged

Addition of custom collection functions for importDeclarations/Specifiers#617
Daniel15 merged 1 commit intofacebook:mainfrom
danieldelcore:import-collection-utils

Conversation

@danieldelcore
Copy link
Contributor

Adds utility methods for import specifiers (similar to the ones provided for JSXElements).

Why?

Import manipulation is probably the most common operation you will do in a codemod, but there are quite a few edge cases to consider when doing so.

For example,

  • Insert imports / specifiers without duplication
  • Renaming import paths
  • Checking for imports (good for early exit conditions)

GLOBALS

insertImportDeclaration
insertImportSpecifiers
findImportDeclarations
findImportSpecifier
findDefaultSpecifier
hasImportSpecifier
hasDefaultImportSpecifier

FILTERS

TBD

Previous PR: #611

@danieldelcore danieldelcore force-pushed the import-collection-utils branch from 25b3bee to 1e7710c Compare July 30, 2024 07:02
@vercel
Copy link

vercel bot commented Jul 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jscodeshift ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2024 7:02am

@danieldelcore danieldelcore marked this pull request as ready for review July 30, 2024 07:23
@danieldelcore
Copy link
Contributor Author

Ok @Daniel15 should be good to go now 😄

@Daniel15
Copy link
Member

Daniel15 commented Aug 2, 2024

Thanks! Tests are passing - looks good.

@Daniel15 Daniel15 merged commit 9e90758 into facebook:main Aug 2, 2024
@Daniel15
Copy link
Member

Daniel15 commented Aug 6, 2024

Released in v17.0.0. Thanks for your contribution!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants