Skip to content

Commit ed3303b

Browse files
cjihrigMylesBorins
authored andcommitted
tools: enable no-useless-constructor lint rule
This commit enables ESLint's no-useless-constructor rule. Note that the documentation examples that only include constructor calls were left in tact. PR-URL: #25055 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 09a99c6 commit ed3303b

5 files changed

Lines changed: 6 additions & 15 deletions

File tree

‎.eslintrc.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ module.exports = {
235235
}],
236236
'no-useless-call': 'error',
237237
'no-useless-concat': 'error',
238+
'no-useless-constructor': 'error',
238239
'no-useless-escape': 'error',
239240
'no-useless-return': 'error',
240241
'no-void': 'error',

‎doc/api/stream.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,7 @@ of the four basic stream classes (`stream.Writable`, `stream.Readable`,
14501450
`stream.Duplex`, or `stream.Transform`), making sure they call the appropriate
14511451
parent class constructor:
14521452

1453+
<!-- eslint-disable no-useless-constructor -->
14531454
```js
14541455
const { Writable } =require('stream');
14551456

@@ -1547,6 +1548,7 @@ changes:
15471548
*`autoDestroy` {boolean} Whether this stream should automatically call
15481549
`.destroy()` on itself after ending. **Default:**`false`.
15491550

1551+
<!-- eslint-disable no-useless-constructor -->
15501552
```js
15511553
const { Writable } =require('stream');
15521554

@@ -1718,11 +1720,6 @@ required elements of a custom [`Writable`][] stream instance:
17181720
const { Writable } =require('stream');
17191721

17201722
classMyWritableextendsWritable {
1721-
constructor(options) {
1722-
super(options);
1723-
// ...
1724-
}
1725-
17261723
_write(chunk, encoding, callback) {
17271724
if (chunk.toString().indexOf('a') >=0) {
17281725
callback(newError('chunk is invalid'));
@@ -1806,6 +1803,7 @@ changes:
18061803
*`autoDestroy` {boolean} Whether this stream should automatically call
18071804
`.destroy()` on itself after ending. **Default:**`false`.
18081805

1806+
<!-- eslint-disable no-useless-constructor -->
18091807
```js
18101808
const { Readable } =require('stream');
18111809

@@ -2064,6 +2062,7 @@ changes:
20642062
*`writableHighWaterMark` {number} Sets `highWaterMark` for the writable side
20652063
of the stream. Has no effect if `highWaterMark` is provided.
20662064

2065+
<!-- eslint-disable no-useless-constructor -->
20672066
```js
20682067
const { Duplex } =require('stream');
20692068

@@ -2218,6 +2217,7 @@ output on the `Readable` side is not consumed.
22182217
*`flush` {Function} Implementation for the [`stream._flush()`][stream-_flush]
22192218
method.
22202219

2220+
<!-- eslint-disable no-useless-constructor -->
22212221
```js
22222222
const { Transform } =require('stream');
22232223

‎lib/perf_hooks.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ function getMilestoneTimestamp(milestoneIdx) {
143143
}
144144

145145
classPerformanceNodeTiming{
146-
constructor(){}
147-
148146
getname(){
149147
return'node';
150148
}

‎lib/v8.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ class DefaultSerializer extends Serializer {
172172
}
173173

174174
classDefaultDeserializerextendsDeserializer{
175-
constructor(buffer){
176-
super(buffer);
177-
}
178-
179175
_readHostObject(){
180176
consttypeIndex=this.readUint32();
181177
constctor=arrayBufferViewTypes[typeIndex];

‎test/parallel/test-stream-writable-null.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ const assert = require('assert');
55
conststream=require('stream');
66

77
classMyWritableextendsstream.Writable{
8-
constructor(opt){
9-
super(opt);
10-
}
11-
128
_write(chunk,encoding,callback){
139
assert.notStrictEqual(chunk,null);
1410
callback();

0 commit comments

Comments
 (0)