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

Update variables to ES6 #2169

Merged
merged 4 commits into from
Dec 30, 2016
Merged

Update variables to ES6 #2169

merged 4 commits into from
Dec 30, 2016

Conversation

davidrbright
Copy link
Contributor

@davidrbright davidrbright commented Dec 27, 2016

Fixes #2168. Updated all variable declarations to respective ES6 variants when applicable. All tests passed. No other code changed.

@markerikson
Copy link
Contributor

Looks pretty good to me. My only real question is whether we want to put this straight into master, or into the next branch that @jimbolla has been playing with. Jim, @timdorr , thoughts?

@jimbolla
Copy link
Contributor

I don't see any problem with either. Should we also add the eslint rules to forbid var, and to prefer const over let when possible?

@markerikson
Copy link
Contributor

Sure, might as well.

@kennetpostigo
Copy link

kennetpostigo commented Dec 27, 2016

I remember seeing a chrome benchmark of let and const vs var a couple weeks ago and var seemed to be optimized by chrome. Not sure if that matters much

@@ -115,13 +115,13 @@ export default function combineReducers(reducers) {
finalReducers[key] = reducers[key]
}
}
var finalReducerKeys = Object.keys(finalReducers)
const finalReducerKeys = Object.keys(finalReducers)

if (NODE_ENV !== 'production') {
var unexpectedKeyCache = {}
Copy link
Contributor Author

@davidrbright davidrbright Dec 27, 2016

Choose a reason for hiding this comment

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

This is one spot, line 121, where I couldn't change to let, without errors failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A fix I had was declaring let unexpectedKeyCache above the conditional check. But I don't know if you guys want an undefined variable floating around in production.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thought, the let fix should be fine, because if it's using variable hoisting as it is. Then defining let before the block is no problem. Let me know what you guys think.

@davidrbright
Copy link
Contributor Author

davidrbright commented Dec 27, 2016

We might have to do another change to add the eslint rule for forbidding var's because line 121 in combineReducers had failing tests when I changed it to let. So either not add the eslint rule, or change the code to accommodate it. I can't think of a good way to fix it, because it's defined in a block, and according to tests it looks like it uses variable hoisting.

@jimbolla
Copy link
Contributor

You could disable the rule on that line with // eslint-disable-line (rule-name) and add a comment why it's not changeable right now.

@davidrbright
Copy link
Contributor Author

@jimbolla I think defining let unexpectedKeyCache above the conditional is fine. It seems the original var declaration is just using hoisting, So defining with let in the main scope works the same. All tests passed when I did it.

@davidrbright
Copy link
Contributor Author

Everything is good to go now. I can also add the eslint rules too. Just let me know what level you want them at.

@jimbolla
Copy link
Contributor

Error is fine I guess.

@davidrbright
Copy link
Contributor Author

Eslint rules added. All lint rules passed. All tests passed. Should be good to go now.

@jimbolla
Copy link
Contributor

LGTM!

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.

4 participants