| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Nit: Indicate what you are preferring it over. Maybe Prefer common.mustNotCall(msg) over common.mustCall(fn, 0) or whatever.
Sorry, something went wrong.
There was a problem hiding this comment.
(Ah, I see it's also in the message supplied to the user. Might not be terrible to put it in the comment overview too, though.)
Sorry, something went wrong.
There was a problem hiding this comment.
Done!
Sorry, something went wrong.
There was a problem hiding this comment.
Seems good to me.
CI: https://ci.nodejs.org/job/node-test-pull-request/7027/
(LGTM but I'd like more eyes, large changes XD)
Sorry, something went wrong.
There was a problem hiding this comment.
Are you using nested ifs instead of lots of && because it looks cleaner?
Sorry, something went wrong.
There was a problem hiding this comment.
Could you at least break these out into one or more helper functions (isCommonMethod(), isMustCall())?
Sorry, something went wrong.
|
cc/ @not-an-aardvark, @silverwind, @targos for the eslint side |
Sorry, something went wrong.
There was a problem hiding this comment.
Linter rule LGTM
Sorry, something went wrong.
There was a problem hiding this comment.
Could you at least break these out into one or more helper functions (isCommonMethod(), isMustCall())?
Sorry, something went wrong.
|
@cjihrig ... updated! new and improved! |
Sorry, something went wrong.
|
Beautiful. One thing I just noticed - do you think it's worth adjusting the argument checking in the lint rule, since common.mustCall(0) would be possible now too? |
Sorry, something went wrong.
|
Good point lol |
Sorry, something went wrong.
Out of interest, is there a reason to allow common.mustCall(0)? If the linter tells you to replace that with common.mustCall() that makes sense to me. |
Sorry, something went wrong.
|
The point is that common.mustCall(0) should be caught by the lint rule. It should be replaced with common.mustNotCall(). common.mustCall(0) was not a valid use of mustCall() prior to this PR. |
Sorry, something went wrong.
Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop
Prefer using `common.mustNotCall()` over `common.mustCall(fn, 0)`
|
@cjihrig ... updated to catch common.mustCall(0) |
Sorry, something went wrong.
Sorry, something went wrong.
|
The rule LGTM. I didn't re-review everything else. I'm assuming that part didn't change. |
Sorry, something went wrong.
|
Only CI failure is unrelated. |
Sorry, something went wrong.
Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: #12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Prefer using `common.mustNotCall()` over `common.mustCall(fn, 0)` PR-URL: #12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
|
This will need to be manually backported to v7.x |
Sorry, something went wrong.
Sorry, something went wrong.
|
ping @jasnell one more time for backport |
Sorry, something went wrong.
Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: #12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Prefer using `common.mustNotCall()` over `common.mustCall(fn, 0)` PR-URL: #12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: #12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Prefer using `common.mustNotCall()` over `common.mustCall(fn, 0)` PR-URL: #12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
| Back | FazBrowse Home | New Git URL |
Throughout the tests, creation of non-op functions is fairly extensive, and it is not uncommon to find common.mustCall(() => {}) or common.mustCall(function() {}), or noop = () => {}; type declarations throughout.
This PR introduces a common.noop non-op function that is used as an alternative to redeclaring nonops all the time.
The common.mustCall() method is also modified such that the fn argument defaults to common.noop if undefined, making it unnecessary to pass in a function when a nonop is needed.
There were also a couple of places where common.mustCall(fn, 0) was used to identify a function that should not be called. These are replace with common.mustNotCall() and a lint rule is added.
Checklist
Affected core subsystem(s)
test, tools