question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

migrate tool ignores parser

See original GitHub issue

Describe the bug When running sb migrate with a parser argument (eg sb migrate --parser=flow storiesof-to-csf --glob 'components/stories/*.js'), the parser is ignored.

To Reproduce Steps to reproduce the behavior:

  1. Create a stories file with flowtype annotations
  2. Run sb migrate --parser=flow storiesof-to-csf --glob 'components/stories/*.js'

Expected behavior The migrate tool converts my stories to CSF format

Screenshots Failure due to babel parser not being able to parse flow types:

 ERR components/stories/midrollToolbar.js Transformation error
SyntaxError: Unexpected token, expected ";" (7:11)
    at _class.raise (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:776:15)
    at _class.unexpected (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:2079:16)
    at _class.semicolon (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:2063:40)
    at _class.parseVarStatement (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:4413:10)
    at _class.parseStatementContent (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:4012:21)
    at _class.parseStatement (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:3962:17)
    at _class.parseBlockOrModuleBlockBody (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:4513:23)
    at _class.parseBlockBody (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:4500:10)
    at _class.parseBlockBody (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:5462:44)
    at _class.parseTopLevel (/Users/jon/.config/yarn/global/node_modules/jscodeshift/node_modules/babylon/lib/index.js:3938:10)

Additional context

The parser option is passed here - https://github.com/storybookjs/storybook/blob/dfe9eb7efc73cd677f44c1ebb3f052ef68b4a3f9/lib/cli/bin/generate.js#L68 - and then ignored here - https://github.com/storybookjs/storybook/blob/dfe9eb7efc73cd677f44c1ebb3f052ef68b4a3f9/lib/cli/lib/migrate.js#L3.

I tried to naively fix it by passing the parserOption through to runCodeMod, but it dies at the prettier stage:

 ERR components/stories/midrollToolbar.js Transformation error (Cannot read property 'process' of undefined)
TypeError: Cannot read property 'process' of undefined
    at buffer (/Users/jon/Developer/web/webpack/node_modules/prettier/parser-flow.js:1:42536)
    at mGt (/Users/jon/Developer/web/webpack/node_modules/prettier/parser-flow.js:1:1429771)
    at e (/Users/jon/Developer/web/webpack/node_modules/prettier/parser-flow.js:1:393)
    at default (/Users/jon/Developer/web/webpack/node_modules/prettier/parser-flow.js:1:19587)
    at /Users/jon/Developer/web/webpack/node_modules/prettier/parser-flow.js:1:16
    at Object.prettierPlugins (/Users/jon/Developer/web/webpack/node_modules/prettier/parser-flow.js:1:139)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Module._compile (/Users/jon/Developer/web/webpack/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Object.newLoader [as .js] (/Users/jon/Developer/web/webpack/node_modules/pirates/lib/index.js:104:7)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mbylstracommented, Jan 30, 2020

Yes, thanks - I also found that. But then I ran into further problems with the transform when it’s run in tsx mode: I opened an issue about this: https://github.com/storybookjs/storybook/issues/9669

0reactions
shilmancommented, Dec 28, 2020

Fixed in #12453 and released in 6.0. Closing!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ts-migrate: A Tool for Migrating to TypeScript at Scale - Medium
It removes all @ts-ignore ¹ instances from the file. If we are converting a JavaScript project to TypeScript, this plugin won't do anything....
Read more >
Understand GWMME error codes - Google Support
Try the Log Analyzer This tool can identify most issues within a few. ... This error can safely be ignored because GWMME continues...
Read more >
Migrating to v6.0.0 - ESLint - Pluggable JavaScript Linter
The ecmaVersion parser option is set to something other than a number, such as the string "2015" . (Previously, a non-number option would...
Read more >
Migrating from ANTLR2 to ANTLR4 - Strumenta
Here at Strumenta, we use ANTLR4 whenever possible, to develop parsers and ... it's supposed to do, just to use the shiny new...
Read more >
Run the Firewall Migration Tool - Cisco
lines that the Firewall Migration Tool cannot parse. ... Ignored Configuration—Details of ASA configuration elements that are ignored because they are not.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found