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 <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent e961060 commit 10ae868

9 files changed

Lines changed: 9 additions & 58 deletions

File tree

‎lib/inspector/promises.js‎

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

6-
classSessionextendsinspector.Session{
7-
constructor(){super();}// eslint-disable-line no-useless-constructor
8-
}
6+
classSessionextendsinspector.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
returnoffset;
954954
}
955955

956-
classFastBufferextendsUint8Array{
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+
classFastBufferextendsUint8Array{}
964957

965958
functionaddBufferPrototypeMethods(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
classAsymmetricKeyObjectextendsKeyObject{
238-
// eslint-disable-next-line no-useless-constructor
239-
constructor(type,handle){
240-
super(type,handle);
241-
}
242-
243238
getasymmetricKeyType(){
244239
returnthis[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
classResultSetextendsSafeSet{
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
classResolveCacheextendsSafeMap{
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
classLoadCacheextendsSafeMap{
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-
classSafeMapextendsMap{
409-
constructor(i){super(i);}// eslint-disable-line no-useless-constructor
410-
},
406+
classSafeMapextendsMap{},
411407
);
412408
primordials.SafeWeakMap=makeSafe(
413409
WeakMap,
414-
classSafeWeakMapextendsWeakMap{
415-
constructor(i){super(i);}// eslint-disable-line no-useless-constructor
416-
},
410+
classSafeWeakMapextendsWeakMap{},
417411
);
418412

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

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

447431
constSafePromise=makeSafe(
448432
Promise,
449-
classSafePromiseextendsPromise{
450-
// eslint-disable-next-line no-useless-constructor
451-
constructor(executor){super(executor);}
452-
},
433+
classSafePromiseextendsPromise{},
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
classInterfaceextendsInterfaceConstructor{
351-
// eslint-disable-next-line no-useless-constructor
352-
constructor(input,output,completer,terminal){
353-
super(input,output,completer,terminal);
354-
}
355351
getcolumns(){
356352
if(this.output?.columns)returnthis.output.columns;
357353
returnInfinity;

‎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
returnclassextendsParser{
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
letaddAbortListener;
2828

2929
classInterfaceextends_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
returnnewPromise((resolve,reject)=>{
3632
letcb=resolve;

0 commit comments

Comments
 (0)