discussion: eslint rule for /test/
- no-unused-vars: [error, {args: after-used, caughtErrors: all}]
#14137
Closed
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