`hasOwnProperty` is not detected with `no-undef`
See original GitHub issueTell 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.
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:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this is working as intended because the global object typically has
Object.prototype
on its prototype chain, so referencing a property likehasOwnProperty
will read that value. I’ve seenhasOwnProperty.call(foo, bar)
used as an alternative toObject.prototype.hasOwnProperty.call(foo, bar)
.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.