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

Cleanup #5

Merged
merged 9 commits into from
Sep 6, 2015
Merged

Cleanup #5

merged 9 commits into from
Sep 6, 2015

Conversation

kahlil
Copy link
Contributor

@kahlil kahlil commented Sep 6, 2015

Introduced some config for linting, editorconfig, gitignore etc.
Also refactored towards es2015 and modularized a bit.

export default function gittenify(store) {
const userMap = {};

for (const u of store.users) {

Choose a reason for hiding this comment

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

const u seems strange here. Wouldn't let fit better? Semantically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RobinThrift const should always be used when you know that the variable will not be modified. Actually the eslint config I added errors here when you use let because u never changes.

Choose a reason for hiding this comment

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

That's what I meant by "Semantically". While the variable inside the block itself doesn't change, the variable "itself" does. If it checks out, it's fine. Just a bit odd ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm interesting, I guess since you are re-declaring it with a const keyword on every turn of that for-loop it is like you are just wiping it away and then initializing it fresh every time so that the variable is actually not being changed but erased and re-declared.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or something...

might need some further research.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Babel doesn't seem to have a problem with it. Good catch though!

Choose a reason for hiding this comment

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

Babel transforms this into for(var u,l=e.users[Symbol.iterator]();!(a=(u=l.next()).done);a=!0). I think the variables in the for-head only get initialized once, hence why I caught it. I could be wrong though. ES6 sure is interesting ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. Then the linter is not working correctly in this case I would say.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to let and turned off the prefer-const eslint rule :)

export default function replaceUsers(el, store, userMap) {
const containers = el.querySelectorAll(containerSelector);

[...containers].forEach((container) => {

Choose a reason for hiding this comment

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

Great use of the spread operator. I love this ES6 stuff 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah so neat!!!
that's actually es7 as far as I know :))

import replaceUsers from './replaceUsers';

export default function gittenify(store) {
const userMap = {};

Choose a reason for hiding this comment

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

We could use a "real" ES6 Map here, just for ES6's sake. But I don't know, how that would play with Chrome's storage. Maybe like this: http://www.2ality.com/2015/08/es6-map-json.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea, but that is out of scope of this pull request. I just want to clean up and give it some structure. You are very welcome to create a new pull request with that feature added though 😄

Choose a reason for hiding this comment

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

Just wanted to mention it for "future reference" ;) Maybe some day I will have time...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just open an issue for that and label it with improvement or something like that :)

@RobinThrift
Copy link

👍 Okay, looks good to me. Somebody else might want to check if it works in their browser too. 🐱

@kahlil
Copy link
Contributor Author

kahlil commented Sep 6, 2015

@RobinThrift thank you!

@kahlil
Copy link
Contributor Author

kahlil commented Sep 6, 2015

That's good enough for me right now. I am merging this in :)

kahlil added a commit that referenced this pull request Sep 6, 2015
@kahlil kahlil merged commit e146fe7 into master Sep 6, 2015
@RobinThrift
Copy link

Okay, great! Cool stuffs!

@kahlil kahlil mentioned this pull request Sep 8, 2015
7 tasks
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.

2 participants