-
Notifications
You must be signed in to change notification settings - Fork 26.7k
assign variables: give a reason for the assignment #656
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
Conversation
@@ -1136,6 +1139,9 @@ Other Style Guides | |||
} | |||
|
|||
const name = getName(); | |||
if (name.indexOf(' ') > -1) { | |||
name = name.split(' ')[ 0 ]; |
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.
this isn't good, since it's reassigning a const
- it will throw.
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.
oops you are right. Should be lets
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.
(also, there shouldn't be spaces inside brackets: [0]
)
removed the first example as it seemed like a duplicate |
LGTM, just needs a fresh rebase :-) thanks! |
The variable assignment wasn't necessary. This gives a reason to have it there
rebased. not sure why I needed to but did it anyway. |
Thanks! If it's on top of latest master I can merge it in locally without a merge commit. |
If you are doing it locally then its trivial to also do the rebase there as well. Not saying there isn't a reason for the process but it makes it harder to for people trying to help. How often should I be rebasing, every time there is a new commit to master, every day, etc,? A submitter should only rebase if there are conflicts or to squash imo. |
I know the examples are contrived but they should at least be best practices in themselves. The variable assignment wasn't necessary. The function could have passed the getter result directly.
https://github.com/airbnb/javascript#13.4
This wasn't necessary:
since it could have been written like this:
This change gives a reason to have it there.