[Bug]: `Object.prototype` builtins should not be used directly
See original GitHub issueVersion
27.0.6
Steps to reproduce
Expected behavior
test: val => val && Object.prototype.hasOwnProperty.call(val, 'foo'),
if (argv.runInBand && Object.prototype.hasOwnProperty.call(argv, 'maxWorkers')) {
Actual behavior
test: val => val && val.hasOwnProperty('foo'),
test: val => val && val.hasOwnProperty('foo'),
Additional context
It is preferable to call certain Object.prototype methods through Object on object instances instead of using the builtins directly.
Objects can have properties that shadow the builtins on Object.prototype, potentially causing unintended behavior or denial-of-service security vulnerabilities.
Environment
N/A
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
JS-0021 · `Object.prototype` builtins should not be used directly
Object.prototype builtins should not be used directly JS-0021. Bug risk ... Do not access Object.prototype method 'hasOwnProperty' from target object.
Read more >no-prototype-builtins - ESLint - Pluggable JavaScript Linter
This rule prevents calling some Object. prototype methods directly from an object. Additionally, objects can have properties that shadow the builtins on Object ......
Read more >Object.hasOwnProperty() yields the ESLint 'no-prototype ...
I am getting the following error: Do not access Object.prototype method 'hasOwnProperty' from target object. It is a 'no-prototype-builtins' error.
Read more >Why do some developers use Object.prototype ... - Nick Ang
Reason 1: objects can be created with no prototype. The first reason is the one cited in ESLint's no-prototype-builtins rule.
Read more >JavaScript static code analysis: Functions should not be empty
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code ... Objects should not be created to be dropped immediately without being used....
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
See https://eslint.org/docs/user-guide
PR very much welcome 🙂
Can add
no-prototype-builtins
lint rule to find all occurences