Skip to content
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

CLI: sb migrate csf-2-to-3 doesn't work glob that uses multiple file extension #20290

Merged

Conversation

kasperpeulen
Copy link
Contributor

@kasperpeulen kasperpeulen commented Dec 15, 2022

Issues: #20265

What I did:

  • This makes tsx the default parser for csf-2-to-3. The tsx parser adds the neccesary jsx and typescript plugin to babel to parse tsx files.

  • Don't transform storybook source code with babel when running jscodeshift. To make it faster, and less noisy messages of:

[BABEL] Note: The code generator has deoptimised the styling of ... as it exceeds the max of 500KB.
  • Inferring the prettier parser from the filepath, which work the same if you use prettier from the command line. And also don't fail when prettier has errors.

I tried setting tsx the default parser for all codemods, but this doesn't work for all codemods for some reason. It seems a bit odd as I don't understand how adding the typescript plugin would affect the AST of non typescript files.

This also means that some codemods can not be used for TS files. Even when manually overriding the parser. Probably it is best, for new codemods, to always default to the "tsx" parser, so that we make sure it works with that config.

How to test:

  • Run "sb migrate csf-2-to-3 --glob="/src//.stories." and see it works on TS and JS files!

@kasperpeulen kasperpeulen added the maintenance User-facing maintenance tasks label Dec 15, 2022
@kasperpeulen kasperpeulen force-pushed the kasper/sb-1119-sb20265-bug-sb-migrate-csf-2-to-3-doesnt branch from d7dbb6f to cab5b51 Compare December 15, 2022 15:27
@kasperpeulen kasperpeulen changed the title CLI: Make tsx default parser for csf-2-to-3 CLI: sb migrate csf-2-to-3 doesn't work glob that uses multiple file extension Dec 15, 2022
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

@kasperpeulen what's going on with unit tests?

@kasperpeulen
Copy link
Contributor Author

@shilman Tests are fixed now. I used the real command with local testing, forget to mock the path in the unit test.

@kasperpeulen kasperpeulen force-pushed the kasper/sb-1119-sb20265-bug-sb-migrate-csf-2-to-3-doesnt branch from fadbf39 to e3172f8 Compare December 18, 2022 09:56
@ndelangen ndelangen merged commit 400915c into next Dec 19, 2022
@ndelangen ndelangen deleted the kasper/sb-1119-sb20265-bug-sb-migrate-csf-2-to-3-doesnt branch December 19, 2022 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants