-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix: properly transform invalid identifiers #226
fix: properly transform invalid identifiers #226
Conversation
🧡 Apologies for missing the case where the transformation of the legacy template component BTW, Jeppe. We could implement some formatting CI to this repo (Prettier probably is the best choice since it supports Svelte, unlike Biome). I'm saying this because I've noticed formatting changes in this PR. |
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.
🙏
@paoloricciuti do you know why GH Actions aren't being runned in this PR? Did you disable it in your fork? (Gave you write-access to the repo so you don't need forks in the future) |
Thanks @JReinhold ...no i did not disable anything at least not by choice...let me check |
Thanks that would be great, probably the easiest solution right now. |
Closing in favor of #246 |
This fix the transform to handle the case where the template name is an invalid identifier.
Before it was using
camelCase
(only for theStory
actually so that was also a bug) but the problem withcamelCase
is that it can lead to the same name from different string. For exampleModal && Trigger
andModal || Trigger
have the samecamelCase
.To fix this i used a small hash function (stolen from the svelte code base) so that if the template is not a valid identifier (which needs to be to be a
Snippet
) it convert it to something liketemplate_skajsh
(which we don't care too much except for stack traces).I don't know if it's a solution that you like but it works.