-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: Avoid id changes after storiesof-to-csf
migration
#8856
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/storybook/monorepo/5c8fki44v |
if (isReserved(key)) { | ||
key = `${key}Story`; | ||
} | ||
let key = upperFirst(camelCase(name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to use pipeline operator here, but I'm not sure whether it's OK with other contributors:
let key = name |> camelCase |> upperFirst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 stage 1 ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use language features that typescript doesn't support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense & is definitely an improvement over the existing behavior.
My one concern is about PascalCase, since I don't know whether we should encourage that convention for story exports. What do you think about changing it to _${camelCase(name)}
in those cases?
Curious to hear what you and others think.
Just my 0.02c camelCase seems more natural in javascript projects /coming from a 20+ years Pascal guy :)/ |
I discussed this a little with @shilman and I think I agree that the "prefix reserved words with _" solution is probably a better way to achieve the same goal. Here's my thought process:
export Welcome = () => <Welcome />; I guess technically there's nothing wrong with a pascal-cased export but I reckon if I was a new user it would put me off. |
But using PascalCase for components in JSX-based frameworks and libraries like React is quite a common practice. And the stories look pretty much like components (even if technically they aren't), and we even allow React hooks in them. So maybe PascalCasing them by default is a good thing? Among other things, it would:
It makes sense to me to update the examples as well. I can do it on approval
Not really. What they actually would see in case of official-storybook is export const ToStorybook = () => <Welcome showApp={linkTo('Button')} />; |
That's a good point @Hypnosphi -- I think I am convinced, although it seems an important change. |
That might be the case for React, but not for any of our other frameworks where we're returning JS objects... My gut still says |
OK. Given that the benefits for React (and maybe other JSX-based) are practical while the downsides for other frameworks are purely stylistical, let me migrate examples and CLI templates then |
storiesof-to-csf
migration
Issue: sometimes running
storiesof-to-csf
codemod leads to story id changesWhat I did
Story
suffix with_
prefix which gets stripped during conversion to id