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

Use Object.prototype in examples #7755

Merged
merged 2 commits into from
Dec 14, 2016
Merged

Conversation

alexreardon
Copy link
Contributor

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 of Object.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 the Object.prototype directly.

@jsf-clabot
Copy link

jsf-clabot commented Dec 13, 2016

CLA assistant check
All committers have signed the CLA.

@eslintbot
Copy link

Thanks for the pull request, @alexreardon! I took a look to make sure it's ready for merging and found some changes are needed:

  • The commit summary needs to begin with a tag (such as Fix: or Update:). Please check out our guide for how to properly format your commit summary and update it on this pull request.

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@mention-bot
Copy link

@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.

@alexreardon
Copy link
Contributor Author

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

@alexreardon alexreardon reopened this Dec 13, 2016
@alexreardon
Copy link
Contributor Author

Okay, so I accidentally clicked the 'close and comment' button 👎 .

Copy link
Member

@not-an-aardvark not-an-aardvark left a 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?

@alexreardon
Copy link
Contributor Author

Yeah I could add that

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@alexreardon
Copy link
Contributor Author

@not-an-aardvark I have updated the PR to include both usages

@not-an-aardvark
Copy link
Member

Thanks! To clarify, I actually just meant changing some of the {} examples to Object.prototype, e.g.

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.

@alexreardon
Copy link
Contributor Author

Oh I see!

As an aside: I have noticed that the []. and {}. shortcuts are used quite a bit in the docs. Would you be open to me extending this pr to include alternative examples above or below every shorthand?

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

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@alexreardon
Copy link
Contributor Author

I have added a commit which fixes all the docs. It turns out there where not that many occurrences. I also prioritised the Object.prototype and Array.prototype usages as they do not create a new Object or Array.

@not-an-aardvark not-an-aardvark added the documentation Relates to ESLint's documentation label Dec 14, 2016
Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@ilyavolodin ilyavolodin merged commit 639b798 into eslint:master Dec 14, 2016
@alexreardon
Copy link
Contributor Author

Cheers!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants