Skip to content

test, tools: add common.noop and common.mustNotCall lint rule

Rodrigo Muino Tomonari requested to merge github/fork/jasnell/common-noop into master

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
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

test, tools

Merge request reports

Loading