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

ESlint config for "Open in Stackblitz" #18511

Open
guidari opened this issue Feb 4, 2025 · 0 comments
Open

ESlint config for "Open in Stackblitz" #18511

guidari opened this issue Feb 4, 2025 · 0 comments
Labels
role: dev 🤖 type: infrastructure 🤖 Issues relating to devops, tech debt, etc.

Comments

@guidari
Copy link
Contributor

guidari commented Feb 4, 2025

Problem: When adding the “Open in StackBlitz” option to stories, we run into issues with how stories need to be written. For example, instead of writing useState, we should write React.useState for @stackblitz/sdk to work correctly.

Solution: We can implement an ESLint rule to validate that stories are written in a way that supports the “Open in StackBlitz” feature.


In the codePreview.tsx file, you can check the rules and adjustments we apply to ensure that Storybook code is transformed correctly into a format that StackBlitz can interpret.

A couple rules we could write:

  • Make sure we don’t import icons with the same names as components. This docs could help
  • Validate if we are using React.HOOK_NAME instead of using the hook it self. E.g. React.useState vs useState
  • Validate if the story has a return statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
role: dev 🤖 type: infrastructure 🤖 Issues relating to devops, tech debt, etc.
Projects
Status: ⏱ Backlog
Development

No branches or pull requests

1 participant