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

Add rule to check name property is a string literal #111

Open
shilman opened this issue Dec 23, 2022 · 5 comments
Open

Add rule to check name property is a string literal #111

shilman opened this issue Dec 23, 2022 · 5 comments
Assignees

Comments

@shilman
Copy link
Member

shilman commented Dec 23, 2022

Is your feature request related to a problem? Please describe.

When overriding a story name it must be a string literal. Not a variable and not a template literal.

https://discord.com/channels/486522875931656193/1054051640946208768/1055259413415481394

Describe the solution you'd like

Check for this and warn the user. Ideally provide fix.

Describe alternatives you've considered

Making CsfFile smarter. But since there will always be limitations to static analysis, we need some kind of linting regardless

Additional context
Add any other context or screenshots about the feature request here.

@IanVS
Copy link
Member

IanVS commented Dec 27, 2022

I also have #74 open, which I think is the same as this. So I closed it out.

@Dschungelabenteuer
Copy link
Member

  • We usually define stories by directly exporting them: export const MyStory (…)
  • CSF is also able to pick ExportNamedDeclarations: export { MyPreviouslyDefinedStory, AnotherOne }
  • However, in this latest case, redefining the Story name on either MyPreviouslyDefinedStory or AnotherOne has no effect

That repro should be self-explanatory. What's your take on this ? Should it be supported or should we create another ESLint rule to warn users who use this pattern that specifying a name property on re-exported declarations has no effect on the actual name being used by Storybook?

I personally do not see any obvious technical reason (performance or code convenience, maybe ?) which prevents us from supporting this, assuming any export ineluctably refers to an actual Story.

@shilman sorry to ping you, just leaving this question here until you find some time, but really nothing urgent :)

@shilman
Copy link
Member Author

shilman commented Jan 14, 2023

@Dschungelabenteuer If we support that export construct but it doesn't respect the name annotation then that sounds like a bug to me.

@Dschungelabenteuer
Copy link
Member

Dschungelabenteuer commented Jan 14, 2023

Fair enough! I'll stick to the original issue for now and see what I can do, thanks!

@Dschungelabenteuer
Copy link
Member

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

No branches or pull requests

4 participants