-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
lib,doc: enable no-prototype-builtins #18750
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ const { parseExpressionAt } = require('internal/deps/acorn/dist/acorn'); | |
| const { inspect } = require('util'); | ||
| const { EOL } = require('os'); | ||
| const nativeModule = require('native_module'); | ||
| const { isPrototypeOf } = Object.prototype; | ||
|
|
||
| // Escape control characters but not \n and \t to keep the line breaks and | ||
| // indentation intact. | ||
|
|
@@ -400,7 +401,7 @@ function expectedException(actual, expected, msg) { | |
| if (expected.prototype !== undefined && actual instanceof expected) { | ||
| return true; | ||
| } | ||
| if (Error.isPrototypeOf(expected)) { | ||
| if (isPrototypeOf.call(Error, expected)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have one concern about using that in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in getOrSetAsyncId shouldn't we really be using an undefined check since it appears to be a lot faster
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @devsnek it still has the problem of potentially inheriting through prototype. I don't know how likely it is though... I'll ping @AndreasMadsen
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reflect.has also seems significantly faster at this point, just as another option |
||
| return false; | ||
| } | ||
| return expected.call({}, actual) === true; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as this is being refactored can you pull hasOwnProperty off at the top like you did with the other files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went for removing as it is not necessary in the example. It is strictly testing for
nulland that has to be explicitly set.