Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix the conversion of private names to public names #275
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
base: main
Are you sure you want to change the base?
Fix the conversion of private names to public names #275
Changes from 4 commits
23d0b2b
ebb3b65
6deefe5
13f065d
00940e2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why are you iterating through the identifier? Shouldn't returning the substring without the initial
-
or_
should be enough?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.
There can be multiple dashes or underscore, removing only one if there is multiple would lead to the variable still being private, see linked issue.
It's just iterating each char until it finds a character that's not an underscore or dash, then returns the string without the iterated part
This is more performant than regex
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.
What about
identifier.replace(Regex(r"^-|^_"),"")
?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.
The correct one would be
identifier.replace(Regex(r"^[-_]+"),"")
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.
And if the returned string is empty then return a generated var
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 habitually avoid regular expressions because they're somewhat more expensive than explicit parsing. If you'd prefer it, I can make the change, but I think the current way does work.
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.
In this case maybe it's better to only run substring(1), otherwise multiple dashes will get replaced to 1 dash still
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.
Why?
_privateToPublic()
should handle multiple dashes gracefully.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.
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.
Generally I'm okay with leaning towards encouraging
-
, since that's definitely the more CSS-style prefix.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.
Yes it's just for the sake of avoiding unecessary changes during a migration, but I definitely don't understand everything that's happening after this runs, because some tests that look like they should fail returning a dash, don't 🤷
Ok, that one fails
So now it's just a question of do we want to preserve the original number of dashes/underscore or not? (My previous implementation did)
This file was deleted.