-
Notifications
You must be signed in to change notification settings - Fork 178
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
feat: consistent function naming with underscores #821
Conversation
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.
That's awesome! Thank you. Actually, you already did a great job; there is only one question left. Please see the comments.
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.
That's awesome! Thank you. Actually, you already did a great job; there is only one question left. Please see the comments.
Actually, it's even more important to make the changes in our docs. (which should also include both versions, with e.g. |
@LeaVerou, it seems to me this PR is also worth merging before |
✅ Deploy Preview for getmavo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
LGTM, my only suggestion would be to abstract the deprecation code away into a function instead of repeating it.
Something like:
function deprecatedFunction(name, oldName, fn = _[name]) {
return function (...args) {
Mavo.warn(`${oldName}() is deprecated and will be removed in the next version of Mavo. Please use ${name}() instead.");
return fn(...args);
}
}
...and to make the docs and tests edits!
In fact, in https://mavo.io/docs/functions/ I think we should have two entries for each of these, with the old one saying "Deprecated alias of xxx()"
Done. |
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.
Can we not remove extra commas please?
a) trailing commas are there for a reason, it means that adding things after is less likely to result in a syntax error
b) even if we wanted to remove trailing commas, this PR is not the place and it increases the size of the diff making it harder to review
Also, this abstracted away the deprecation code, but is not using it in all three places where it's needed.
We should expose it somewhere, so that other modules can use it as well (or even plugins).
Sorry about that. I thought they were some leftovers from a code formatter (e.g., Prettier). Fixed it.
I hesitated to put it into |
Yeah, I can't think of a better place either, so utils it is. Or |
Then, I believe it's ready for your review. Again. 😅 |
Actually I know where it should live! On |
Honestly, I was also trying to “house” Suppose we have the following code (where fromlast: $u.deprecatedFunction("from_last", "fromlast") And since I suspect that we can do something like this (and it works) fromlast: (...args) => $u.deprecatedFunction("from_last", "fromlast").call(this, ...args) But I'm unsure whether it's the correct way to do this. What am I missing? |
Just move it up? E.g. let $u = {
/* utils here */
};
Mavo.Functions = {
/* ... */
util: $u
} |
It worked! 🥳 Thank you. |
@norbitrial, thank you so much for your work! |
This PR is a solution for #793 issue.
Function calls are tested after renaming and working exact the same way as before. There are extra warnings on the console for old function calls for the following cases:
groupby()
function call,fromlast()
andtofirst()
calls.Let me know if you have any suggestions. Thank you! 🙇 👍