Skip to content

Commit 10ae868

Browse files
Renegade334richardlau
authored andcommitted
lib: revert to using default derived class constructors
PR-URL: #59650 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent e961060 commit 10ae868

File tree

9 files changed

+9
-58
lines changed

9 files changed

+9
-58
lines changed

lib/inspector/promises.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
const inspector = require('inspector');
44
const { promisify } = require('internal/util');
55

6-
class Session extends inspector.Session {
7-
constructor() { super(); } // eslint-disable-line no-useless-constructor
8-
}
6+
class Session extends inspector.Session {}
97
Session.prototype.post = promisify(inspector.Session.prototype.post);
108

119
module.exports = {

lib/internal/buffer.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -953,14 +953,7 @@ function writeFloatBackwards(val, offset = 0) {
953953
return offset;
954954
}
955955

956-
class FastBuffer extends Uint8Array {
957-
// Using an explicit constructor here is necessary to avoid relying on
958-
// `Array.prototype[Symbol.iterator]`, which can be mutated by users.
959-
// eslint-disable-next-line no-useless-constructor
960-
constructor(bufferOrLength, byteOffset, length) {
961-
super(bufferOrLength, byteOffset, length);
962-
}
963-
}
956+
class FastBuffer extends Uint8Array {}
964957

965958
function addBufferPrototypeMethods(proto) {
966959
proto.readBigUInt64LE = readBigUInt64LE;

lib/internal/crypto/keys.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,6 @@ const {
235235
}
236236

237237
class AsymmetricKeyObject extends KeyObject {
238-
// eslint-disable-next-line no-useless-constructor
239-
constructor(type, handle) {
240-
super(type, handle);
241-
}
242-
243238
get asymmetricKeyType() {
244239
return this[kAsymmetricKeyType] ||= this[kHandle].getAsymmetricKeyType();
245240
}

lib/internal/fs/glob.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ class Pattern {
240240
class ResultSet extends SafeSet {
241241
#root = '.';
242242
#isExcluded = () => false;
243-
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
244243

245244
setup(root, isExcludedFn) {
246245
this.#root = root;

lib/internal/modules/esm/module_map.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const { validateString } = require('internal/validators');
2323
* This cache is *not* used when custom loaders are registered.
2424
*/
2525
class ResolveCache extends SafeMap {
26-
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
27-
2826
/**
2927
* Generates the internal serialized cache key and returns it along the actual cache object.
3028
*
@@ -87,7 +85,6 @@ class ResolveCache extends SafeMap {
8785
* Cache the results of the `load` step of the module resolution and loading process.
8886
*/
8987
class LoadCache extends SafeMap {
90-
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
9188
get(url, type = kImplicitTypeAttribute) {
9289
validateString(url, 'url');
9390
validateString(type, 'type');

lib/internal/per_context/primordials.js

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -401,55 +401,36 @@ primordials.makeSafe = makeSafe;
401401

402402
// Subclass the constructors because we need to use their prototype
403403
// methods later.
404-
// Defining the `constructor` is necessary here to avoid the default
405-
// constructor which uses the user-mutable `%ArrayIteratorPrototype%.next`.
406404
primordials.SafeMap = makeSafe(
407405
Map,
408-
class SafeMap extends Map {
409-
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
410-
},
406+
class SafeMap extends Map {},
411407
);
412408
primordials.SafeWeakMap = makeSafe(
413409
WeakMap,
414-
class SafeWeakMap extends WeakMap {
415-
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
416-
},
410+
class SafeWeakMap extends WeakMap {},
417411
);
418412

419413
primordials.SafeSet = makeSafe(
420414
Set,
421-
class SafeSet extends Set {
422-
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
423-
},
415+
class SafeSet extends Set {},
424416
);
425417
primordials.SafeWeakSet = makeSafe(
426418
WeakSet,
427-
class SafeWeakSet extends WeakSet {
428-
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
429-
},
419+
class SafeWeakSet extends WeakSet {},
430420
);
431421

432422
primordials.SafeFinalizationRegistry = makeSafe(
433423
FinalizationRegistry,
434-
class SafeFinalizationRegistry extends FinalizationRegistry {
435-
// eslint-disable-next-line no-useless-constructor
436-
constructor(cleanupCallback) { super(cleanupCallback); }
437-
},
424+
class SafeFinalizationRegistry extends FinalizationRegistry {},
438425
);
439426
primordials.SafeWeakRef = makeSafe(
440427
WeakRef,
441-
class SafeWeakRef extends WeakRef {
442-
// eslint-disable-next-line no-useless-constructor
443-
constructor(target) { super(target); }
444-
},
428+
class SafeWeakRef extends WeakRef {},
445429
);
446430

447431
const SafePromise = makeSafe(
448432
Promise,
449-
class SafePromise extends Promise {
450-
// eslint-disable-next-line no-useless-constructor
451-
constructor(executor) { super(executor); }
452-
},
433+
class SafePromise extends Promise {},
453434
);
454435

455436
/**

lib/internal/readline/interface.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,6 @@ ObjectSetPrototypeOf(InterfaceConstructor.prototype, EventEmitter.prototype);
348348
ObjectSetPrototypeOf(InterfaceConstructor, EventEmitter);
349349

350350
class Interface extends InterfaceConstructor {
351-
// eslint-disable-next-line no-useless-constructor
352-
constructor(input, output, completer, terminal) {
353-
super(input, output, completer, terminal);
354-
}
355351
get columns() {
356352
if (this.output?.columns) return this.output.columns;
357353
return Infinity;

lib/internal/repl/utils.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ function isRecoverableError(e, code) {
9292
.extend(
9393
(Parser) => {
9494
return class extends Parser {
95-
// eslint-disable-next-line no-useless-constructor
96-
constructor(options, input, startPos) {
97-
super(options, input, startPos);
98-
}
9995
nextToken() {
10096
super.nextToken();
10197
if (this.type === tt.eof)

lib/readline/promises.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ const {
2727
let addAbortListener;
2828

2929
class Interface extends _Interface {
30-
// eslint-disable-next-line no-useless-constructor
31-
constructor(input, output, completer, terminal) {
32-
super(input, output, completer, terminal);
33-
}
3430
question(query, options = kEmptyObject) {
3531
return new Promise((resolve, reject) => {
3632
let cb = resolve;

0 commit comments

Comments
 (0)