Skip to content

feat(import-assertions-to-attributes): introduce #89

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AugustinMauroy
Copy link
Member

@AugustinMauroy AugustinMauroy commented Jun 23, 2025

description

  • import attribute in import statement
  • import attribute in dynamic import
  • readme

Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

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

A good start! And nice test fixtures :)

I think import-assertions-to-attributes would be a better name.

@AugustinMauroy AugustinMauroy marked this pull request as ready for review June 24, 2025 09:34
@AugustinMauroy AugustinMauroy requested review from a team and Copilot June 24, 2025 09:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces a codemod to update import assertions by replacing the legacy "assert" attribute with the new "with" syntax, while also adding tests and updating project configuration files.

  • Implements transformation logic for both static and dynamic imports in src/workflow.ts
  • Adds tests and snapshots in various formats (mjs, js, cjs, and edge cases) to verify the codemod’s changes
  • Updates configuration files (tsconfig.json, package.json, .codemodrc.json, biome.jsonc) to support the new codemod

Reviewed Changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
recipes/import-assertions-to-attributes/tsconfig.json Adds configuration for TypeScript compilation
recipes/import-assertions-to-attributes/tests/workflow.test.ts Introduces tests to run the codemod functionality
recipes/import-assertions-to-attributes/tests/workflow.test.snap.cjs Provides snapshot tests for expected codemod outcomes
recipes/import-assertions-to-attributes/tests/fixtures/* Contains sample files using both old and new import syntaxes
recipes/import-assertions-to-attributes/tests/expected/* Provides expected file outputs after codemod transformation
recipes/import-assertions-to-attributes/src/workflow.ts Implements the codemod logic to replace "assert" with "with"
recipes/import-assertions-to-attributes/package.json Defines package metadata and scripts for testing and running the codemod
recipes/import-assertions-to-attributes/.codemodrc.json Configures codemod runtime settings
biome.jsonc Updates ignore settings to exclude test fixtures and expected files

@AugustinMauroy AugustinMauroy changed the title fea(import-attributes): introduce feat(import-attributes): introduce Jun 24, 2025
@AugustinMauroy
Copy link
Member Author

cc @alexbit-codemod What I have produced is still different from what CodeMod studio offers. Could you give me some feedback on the best approach?

@AugustinMauroy AugustinMauroy force-pushed the import-attribute branch 2 times, most recently from ff1f364 to 90c99de Compare June 27, 2025 09:10
@AugustinMauroy AugustinMauroy changed the title feat(import-attributes): introduce feat(import-assertions-to-attributes): introduce Jun 27, 2025
@AugustinMauroy AugustinMauroy requested a review from a team June 27, 2025 09:11
Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

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

looking good!

Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

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

W00t! 🙌

Comment on lines +27 to +28
importNode.children().map(child => {
if (child.kind() === 'assert' && child.text() === 'assert') {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I expected this can be handled above in the ast grep, but it may well be a case of "6 of one, ½ a dozen of the other".

Copy link
Member Author

Choose a reason for hiding this comment

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

for strange reason if you use kind: 'assert' in query it's throw an error

@AugustinMauroy AugustinMauroy force-pushed the import-attribute branch 3 times, most recently from 540dc7f to d3b3fc3 Compare July 17, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

3 participants