-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Use Object.prototype
in examples
#7755
Conversation
Thanks for the pull request, @alexreardon! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
@alexreardon, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DrewML and @scriptdaemon to be potential reviewers. |
It looks like there was some PR conventions I was not aware of. I will update the PR if you guys are happy with the change. Otherwise I won't worry about fixing it up. Cheers |
Okay, so I accidentally clicked the 'close and comment' button 👎 . |
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.
Thanks for the pull request!
I think having Object.prototype
examples is fine, but some users might still prefer the {}.hasOwnProperty
style. Maybe it would be better if we split the three examples to indicate that there are multiple options?
Yeah I could add that |
LGTM |
LGTM |
@not-an-aardvark I have updated the PR to include both usages |
Thanks! To clarify, I actually just meant changing some of the var hasBarProperty = Object.prototype.hasOwnProperty.call(foo, "bar");
var isPrototypeOfBar = Object.prototype.isPrototypeOf.call(foo, bar);
var barIsEnumerable = {}.propertyIsEnumerable.call(foo, "bar"); Sorry about the misunderstanding. That said, the wording that you used also works. |
Oh I see! As an aside: I have noticed that the For example no-extra-parens.md would become: ({}.toString.call());
(Object.prototype.toString.call()); or (Object.prototype.toString.call());
({}.toString.call()); And as you suggested, docs that use multiple examples can have the two styles interleaved |
LGTM |
LGTM |
I have added a commit which fixes all the docs. It turns out there where not that many occurrences. I also prioritised the |
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.
LGTM. Thanks!
Cheers! |
What is the purpose of this pull request? (put an "X" next to item)
[X ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Updating documentation for
no-prototype-builtins
Is there anything you'd like reviewers to focus on?
I thought rather than encouraging people to use
{}.prototype.hasOwnProperty.call
it would be better to encourage the use ofObject.prototype.
as it does not create a new object for the purpose of using the newly created objects prototype functions, but rather just borrows the function from theObject.prototype
directly.