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

Remove underscore #331

Merged
merged 15 commits into from
Jun 4, 2021
Merged

Remove underscore #331

merged 15 commits into from
Jun 4, 2021

Conversation

harryadel
Copy link
Contributor

@harryadel harryadel commented Apr 27, 2021

Please bear with me as this my first time contributing to the Blaze project.

The goal of this pull request is to:

  • Remove underscore and all of its methods in the code
  • Modernize the code base

Both test:ci and test:watch yield no errors.

That's for the code part but the site Hexo server isn't working. I noticed it reads jsdoc comments from several files like builtins.js, preamble.js and couple more so I reverted the linting on those files but then a weird error showed up in the browser

Uncaught SyntaxError: Invalid regular expression: /(?:[ ›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><])|[

I tried reverting the linting on the whole project and even updating the dependencies to the latest in attempt at least to get a more readable error but in vain.

Screenshot_2021-04-27_19-36-07

I attempted to remove the underscore dependency from site directory but then reverted my changes so you guys can have easier time debugging things.

@StorytellerCZ
Copy link
Collaborator

That is a big PR. A lot of it is just change in codying style, which needlessly bloats this PR. Could you maybe separate those into its own PR?

@harryadel
Copy link
Contributor Author

So split the code modernization into its own PR?

@harryadel
Copy link
Contributor Author

@StorytellerCZ Done!

@harryadel
Copy link
Contributor Author

I'll open up the modernization PR once this one gets merged. 👍

Copy link
Collaborator

@StorytellerCZ StorytellerCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I'm thinking that if we can combine this together with removal of jQuery and general modernization that you proposed, then we can do major version bump.

@harryadel
Copy link
Contributor Author

harryadel commented Apr 30, 2021

Looks good to me. I'm thinking that if we can combine this together with removal of jQuery and general modernization that you proposed, then we can do major version bump.

The removal of jQuery would definitely require a major version bump because as @jankapunkt pointed out people's Blaze code is making heavy use of internal jQuery method.

This requires very precise planning to ensure the API is not breaking (think of templateInstance.$(...))

Copy link
Collaborator

@filipenevola filipenevola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @harryadel , thank you for the work here.

For the review to be effective we need to have PRs that are doing only one thing.

Could you keep only the underscore changes in this PR so we can move forward with it?

@harryadel
Copy link
Contributor Author

@filipenevola There's nothing but underscore changes. I've removed the modernization commits as Jan recommended.

@StorytellerCZ
Copy link
Collaborator

@harryadel I think the issue there is that your IDE or something automatic also "fixed" lot of the code around.

@jankapunkt
Copy link
Collaborator

As far as I saw, that was mostly lint fixes which is why I thought them to be ok

@harryadel
Copy link
Contributor Author

I see so the problem lies with the extra linting. Ok, will remove it and notify you guys.

@harryadel
Copy link
Contributor Author

@filipenevola I guess it's ready now

Copy link
Collaborator

@filipenevola filipenevola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments ;)

@@ -37,8 +37,9 @@ Blaze.With = function (data, contentFunc) {
*/
Blaze._attachBindingsToView = function (bindings, view) {
view.onViewCreated(function () {
_.each(bindings, function (binding, name) {
view._scopeBindings[name] = new ReactiveVar;
Object.keys(bindings).forEach(function (name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.entries is better in this case


eachView.argVar.set(arg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change replacing underscore?

@@ -0,0 +1,25 @@
has = function (obj, key) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't expose anything globally, use exports / imports instead.

maybe it would be better to use specific modules of lodash instead of reimplementing these functions here.

@harryadel
Copy link
Contributor Author

@filipenevola friendly ping, please let me know what you think.

Copy link
Collaborator

@filipenevola filipenevola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still places where you should use a different Object utility and also some places where you should use lodash.

packages/blaze/template.js Outdated Show resolved Hide resolved
packages/blaze/view.js Show resolved Hide resolved
packages/caching-html-compiler/caching-html-compiler.js Outdated Show resolved Hide resolved
packages/spacebars-compiler/codegen.js Outdated Show resolved Hide resolved
packages/templating-runtime/dynamic.js Outdated Show resolved Hide resolved
packages/templating-tools/compile-tags-with-spacebars.js Outdated Show resolved Hide resolved
@harryadel
Copy link
Contributor Author

harryadel commented May 13, 2021

So the problem that was causing the site to fail was the non existence of files within the themes directory which is fixed by git submodule update --init --recursive. Should've cloned recursively as suggested in the constributing.md. 😅

But there's a tiny problem with installing modules for the site though which I'll fix in a different PR.

@harryadel
Copy link
Contributor Author

Copy link
Collaborator

@filipenevola filipenevola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

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

Successfully merging this pull request may close these issues.

None yet

4 participants