Skip to content

discussion: eslint rule for /test/ - no-unused-vars: [error, {args: after-used, caughtErrors: all}] #14137

Closed
@refack

Description

  • Version: *
  • Platform: *
  • Subsystem: test

There still seems to be a small performance advantage to using functors that match the signature of the invocation:

> var o = 0;
> function trig(a, b, f) { const x = f(a,b); o = x; };
> function trig2(b, a, f) { const x = f(a,b); o = x; };
> console.time('0'); for (let i = 0; i < 1e8; ++i) (i%2 ? trig : trig2)(i+1, i+2, () => i);console.timeEnd('0')
0: 7371.239ms
> console.time('a,b'); for (let i = 0; i < 1e8; ++i) (i%2 ? trig : trig2)(i+1, i+2, (a,b) => i);console.timeEnd('a,b')
a,b: 7066.650ms

For for explicitness sake, would we consider requiring no unused arguments (or exception) in /test/?
i.e.:

/* eslint no-unused-vars: [error, {args: after-used, caughtErrors: all }] */

// "baz" is defined but never used
(function(foo, bar, baz) {
    return bar;
})();

try {
  foo();
} catch (e) {
  // "e" is defined but never used
}

Current impact on /test/: 297 error in 195 files

/cc @nodejs/testing @nodejs/performance

Metadata

Assignees

No one assigned

    Labels

    discussIssues opened for discussions and feedbacks.performanceIssues and PRs related to the performance of Node.js.testIssues and PRs related to the tests.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions