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

Removed globals, "Controller as" Syntax, Simplified functions #1559

Closed
wants to merge 6 commits into from
Closed

Removed globals, "Controller as" Syntax, Simplified functions #1559

wants to merge 6 commits into from

Conversation

dmitriz
Copy link
Contributor

@dmitriz dmitriz commented Dec 22, 2015

  • Removed the global todomvc as it promotes a bad practice. Used modular approach instead. All modules are now visible in app.js and named as their files, following the principle of least surprise.
  • Enclosed in anonymous functions as recommended in https://github.com/tastejs/todomvc/blob/master/codestyle.md
  • Replaced the "$scope soup" by the recommended "Controller as" syntax. Improves readability of the template by making clear distinction between controller-defined properties/methods and the rest, among other benefits. All properties/methods are now named exactly the same in both template and controller.
  • Simplified functions and watchers. No more need to use $filter in controller, eliminated unnecessarily complexity.
  • More consistent naming. newTodo is made a todo, rather than a todo title.

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @passy, @IgorMinar and @sindresorhus to be potential reviewers

@dmitriz
Copy link
Contributor Author

dmitriz commented Dec 22, 2015

Fixed the space warning.

Can change var TC = this; to var self = this; if needed, but this is sort of killing part of the improved readability.

@samccone
Copy link
Member

Thanks for the PR @dmitriz I left come code review comments!

@samccone
Copy link
Member

@dmitriz mind fixing the jscs errors (which is causing CI to fail)

As for the self complaint from jscs, as you pointed out what you are doing is idiomatic angular, so lets just disable that specific rule via an inline comment jscs-dev/node-jscs#486

👍 thanks for this awesome work and let me know if you have any other questions...


on a side note we have several angular examples that could use this work ^

https://github.com/tastejs/todomvc/tree/master/examples/angularjs
https://github.com/tastejs/todomvc/tree/master/examples/angularjs_require

Would be supppper amazing if you wanted to update these as well 😄

@dmitriz
Copy link
Contributor Author

dmitriz commented Dec 23, 2015

Thanks! You are most welcome :)
Will have a look at the other examples once this one is done.

The 2 questions remain:

  • How to undo the past commit elegantly?
  • Which rule to disable for the weird "self=this" warning??? No luck googling :(

@samccone
Copy link
Member

  1. You will want to do an interactive rebase

Checkout this awesome walkthrough
https://robots.thoughtbot.com/git-interactive-rebase-squash-amend-rewriting-history

here is the rule
http://jscs.info/rule/safeContextKeyword

we can disable with

//jscs:disable safeContextKeyword
...<code>..
//jscs:enable

@dmitriz
Copy link
Contributor Author

dmitriz commented Dec 23, 2015

  1. Thanks - it works (though the rule looks different)!

  2. Great article but didn't reveal the trick - found it here: http://christoph.ruegg.name/blog/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html

@samccone
Copy link
Member

oh oh I did not realize that was your question (pushing to a remote) :) glad you got it

@samccone
Copy link
Member

@dmitriz in the future you should be able to force push the update over this branch without having to open a new PR... no worries though

@samccone samccone closed this Dec 23, 2015
@dmitriz dmitriz deleted the my-exp branch December 23, 2015 04:34
@dmitriz
Copy link
Contributor Author

dmitriz commented Dec 23, 2015

Was trying to stay safe but thanks for the head up :)

@dmitriz
Copy link
Contributor Author

dmitriz commented Dec 24, 2015

Actually now I remember why I didn't do "force push"!

In one of my PRs to the Angular UI Bootstrap project I've added my own Gulp wrapper on top of their Grunt tasks but they wanted me to remove it. So I erased it from the git history and force pushed back.

The result was the loss of all in-code comments by the maintainers and my replies to them on Github!
The only change was in the Gulpfile, so none of those files were affected and the last thing I expect was them to disappear. Yet they were all gone!

All commits were still there and you would think the in-code comments would stay referenced from them but this does not seem how Github handles them, unfortunately. I found our discussion there useful and expected to be able to reference it in the future, so it was quite a bad surprise to see them all gone :(

Since then I stay away from force push.

samccone added a commit that referenced this pull request Dec 24, 2015
Removed globals, readability, simplified or removed components - replace PR #1559
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.

3 participants