Skip to content

Commit 1a93df8

Browse files
Renegade334targos
authored andcommitted
lib: revert to using default derived class constructors
PR-URL: #59650 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent df63d37 commit 1a93df8

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
@@ -960,14 +960,7 @@ function writeFloatBackwards(val, offset = 0) {
960960
return offset;
961961
}
962962

963-
class FastBuffer extends Uint8Array {
964-
// Using an explicit constructor here is necessary to avoid relying on
965-
// `Array.prototype[Symbol.iterator]`, which can be mutated by users.
966-
// eslint-disable-next-line no-useless-constructor
967-
constructor(bufferOrLength, byteOffset, length) {
968-
super(bufferOrLength, byteOffset, length);
969-
}
970-
}
963+
class FastBuffer extends Uint8Array {}
971964

972965
function addBufferPrototypeMethods(proto) {
973966
proto.readBigUInt64LE = readBigUInt64LE;

lib/internal/crypto/keys.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,6 @@ const {
253253
}
254254

255255
class AsymmetricKeyObject extends KeyObject {
256-
// eslint-disable-next-line no-useless-constructor
257-
constructor(type, handle) {
258-
super(type, handle);
259-
}
260-
261256
get asymmetricKeyType() {
262257
return this[kAsymmetricKeyType] ||= this[kHandle].getAsymmetricKeyType();
263258
}

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
*
@@ -93,7 +91,6 @@ class ResolveCache extends SafeMap {
9391
* Cache the results of the `load` step of the module resolution and loading process.
9492
*/
9593
class LoadCache extends SafeMap {
96-
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
9794
get(url, type = kImplicitTypeAttribute) {
9895
validateString(url, 'url');
9996
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
@@ -359,10 +359,6 @@ ObjectSetPrototypeOf(InterfaceConstructor.prototype, EventEmitter.prototype);
359359
ObjectSetPrototypeOf(InterfaceConstructor, EventEmitter);
360360

361361
class Interface extends InterfaceConstructor {
362-
// eslint-disable-next-line no-useless-constructor
363-
constructor(input, output, completer, terminal) {
364-
super(input, output, completer, terminal);
365-
}
366362
get columns() {
367363
if (this.output?.columns) return this.output.columns;
368364
return Infinity;

lib/internal/repl/utils.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ function isRecoverableError(e, code) {
9797
.extend(
9898
(Parser) => {
9999
return class extends Parser {
100-
// eslint-disable-next-line no-useless-constructor
101-
constructor(options, input, startPos) {
102-
super(options, input, startPos);
103-
}
104100
nextToken() {
105101
super.nextToken();
106102
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)