-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
Refactored native calls #1826
Refactored native calls #1826
Conversation
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.
While I admire the effort I don't see how this would prevent anything. Today, bugs with native functions happen because we forget to check/fail to see that native functions are used directly.
Having them accessible through modules won't change anything regarding this, but will make it easier to do, since we can skip the ceremony.
In that respect, this is worth doing, but I can't see how we can ensure we are not introducing more bugs without an automatic checks that fails code using native functions.
The problem today is we assume the native is still functional/not broken. If we just stored a copy beforehand, we wouldn't face this problem... unless it was broken before sinon is loaded and then we're hosed unless we do something fancier like getting clean |
At least that's one of the problems 😃 It wouldn't prevent stuff like #1796 from popping up in future PRs, but at least it would serve as a reminder and also avoid the whole "is this native function still functional?" thing in the cases where we remember to use a cached reference. |
I think it would make it easier to see. Calling |
I like where this PR is going, more defensive code is a good approach for a library. |
I think I have found all we need for such an eslint plugin! Use the skeleton for
|
That looks promising! |
8eb49be
to
421bb3d
Compare
Pull Request Test Coverage Report for Build 2597
💛 - Coveralls |
I like the approach of using static analysis better than introducing more code. What do you think @fearphage? |
Is it an either or situation? An eslint-style rule will not make the code work correctly. |
My understanding was that it could be used for preventing us from merging code that was vulnerable to end users overriding native methods. If that was incorrect, then I agree, it won't. |
Maybe |
this rule started life as a direct copy of the built-in ESLint rule: https://eslint.org/docs/rules/no-prototype-builtins
this rule started life as a direct copy of the built-in ESLint rule: https://eslint.org/docs/rules/no-prototype-builtins
@akdor1154 |
421bb3d
to
a54020d
Compare
FYI this branch now passes with the new custom eslint rule (#1858). |
Great, then I suggest merging this first and the eslint rule second to see the build pass. Thanks for the work! |
👍 |
this rule started life as a direct copy of the built-in ESLint rule: https://eslint.org/docs/rules/no-prototype-builtins
this rule started life as a direct copy of the built-in ESLint rule: https://eslint.org/docs/rules/no-prototype-builtins
So I've seen this method used in jQuery to handle native method calls. I haven't checked here, but they all get compiled away cleanly in jQuery. I just touched a few files at first to see what everyone thought of the methodology. This would be a global change to combat things like #1796 from popping up.
Note: It's incomplete, but the tests are green.