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

"'hasOwnProperty' is a really bad name" #770

Closed
jashkenas opened this issue Dec 11, 2012 · 5 comments
Closed

"'hasOwnProperty' is a really bad name" #770

jashkenas opened this issue Dec 11, 2012 · 5 comments
Assignees
Milestone

Comments

@jashkenas
Copy link

I was curious why JSHint has an error for:

'hasOwnProperty' is a really bad name

When you're writing code like this:

var hasOwnProperty = {}.hasOwnProperty;

... unless it's a leftover bug from the JSLint port:

http://tech.groups.yahoo.com/group/jslint_com/message/282

Is it something that can be fixed in an update? Or is there a better reason?

@ghost ghost assigned valueof Dec 11, 2012
@valueof
Copy link
Member

valueof commented Dec 11, 2012

Yeah, that looks like a bug. We should warn about hasOwnProperty only if someone defines a new property/method with such name. I'll make sure it's fixed before the next release. Thanks!

@webuniverseio
Copy link

Hi, is there a way to suppress this warning? I'm using localstorage fallback from https://developer.mozilla.org/en-US/docs/DOM/Storage#localStorage (at the bottom of that section) which overwrites hasOwnProperty method.

@valueof
Copy link
Member

valueof commented Feb 28, 2013

You can use /* jshint -W001 */

@webuniverseio
Copy link

I see. This is not scoped suppression, right? Also is there a way to turn warning back after /* jshint -W001 */?
Thank you.

@valueof
Copy link
Member

valueof commented Mar 3, 2013

It is function scoped.

jugglinmike pushed a commit to jugglinmike/jshint that referenced this issue Oct 21, 2014
We don't need to warn about 'var hasOwnProperty = ...' and such so
now we only warn about the following cases:

	var obj = { hasOwnProperty: ... };
	obj.hasOwnProperty = ...;
	obj['hasOwnProperty'] = ...;

Closes jshintGH-770.
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

No branches or pull requests

3 participants