question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`hasOwnProperty` is not detected with `no-undef`

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.3.0
  • Node Version: 11.0.0-pre
  • npm Version: 6.2.0

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

no-undef: error

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Demo

What did you expect to happen?

An error should be reported.

What actually happened? Please include the actual, raw output from ESLint.

Nothing is reported. It is specific to this function name.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Aug 12, 2018

I think this is working as intended because the global object typically has Object.prototype on its prototype chain, so referencing a property like hasOwnProperty will read that value. I’ve seen hasOwnProperty.call(foo, bar) used as an alternative to Object.prototype.hasOwnProperty.call(foo, bar).

0reactions
BridgeARcommented, Aug 12, 2018

Oh, you are right. Thanks for pointing this out! I just ran into an issue with it because I used uncurryThis to prevent tampering of the globals… I guess this is a special case without an ideal solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

hasOwnProperty is not a function in Node.js? - Stack Overflow
A way around the error is to call hasOwnProperty on Object explicitly, and bind it to the object, like so: // Calls "hasOwnProperty"...
Read more >
Object.prototype.hasOwnProperty() - JavaScript | MDN
The method returns false if the property is inherited, or has not been declared at all. Unlike the in operator, this method does...
Read more >
Converse.js API Documentation Source: headless/dist ...
"If data contains a code point that is not one of // // U+002B (+) // U+002F ... throw new TypeError(sprintf('[sprintf] expecting number...
Read more >
chromium/src/third_party - Git at Google
locale, for this reason we need to detect this case and redefine lowercase/uppercase ... Slow path for objects which do not have a...
Read more >
ESLint equivalents in Elm - Elmcraft
When it comes to detecting bugs and problematic patterns, ... It is therefore not necessary to use a linter in your project, as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found