Skip to content

Commit 694ea00

Browse files
cjihrigBethGriggs
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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8d953b7 commit 694ea00

File tree

5 files changed

+6
-15
lines changed

5 files changed

+6
-15
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ module.exports = {
223223
}],
224224
'no-useless-call': 'error',
225225
'no-useless-concat': 'error',
226+
'no-useless-constructor': 'error',
226227
'no-useless-escape': 'error',
227228
'no-useless-return': 'error',
228229
'no-void': 'error',

doc/api/stream.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,7 @@ of the four basic stream classes (`stream.Writable`, `stream.Readable`,
14411441
`stream.Duplex`, or `stream.Transform`), making sure they call the appropriate
14421442
parent class constructor:
14431443

1444+
<!-- eslint-disable no-useless-constructor -->
14441445
```js
14451446
const { Writable } = require('stream');
14461447

@@ -1531,6 +1532,7 @@ changes:
15311532
* `final` {Function} Implementation for the
15321533
[`stream._final()`][stream-_final] method.
15331534

1535+
<!-- eslint-disable no-useless-constructor -->
15341536
```js
15351537
const { Writable } = require('stream');
15361538

@@ -1702,11 +1704,6 @@ required elements of a custom [`Writable`][] stream instance:
17021704
const { Writable } = require('stream');
17031705

17041706
class MyWritable extends Writable {
1705-
constructor(options) {
1706-
super(options);
1707-
// ...
1708-
}
1709-
17101707
_write(chunk, encoding, callback) {
17111708
if (chunk.toString().indexOf('a') >= 0) {
17121709
callback(new Error('chunk is invalid'));
@@ -1780,6 +1777,7 @@ constructor and implement the `readable._read()` method.
17801777
* `destroy` {Function} Implementation for the
17811778
[`stream._destroy()`][readable-_destroy] method.
17821779

1780+
<!-- eslint-disable no-useless-constructor -->
17831781
```js
17841782
const { Readable } = require('stream');
17851783

@@ -2038,6 +2036,7 @@ changes:
20382036
* `writableHighWaterMark` {number} Sets `highWaterMark` for the writable side
20392037
of the stream. Has no effect if `highWaterMark` is provided.
20402038

2039+
<!-- eslint-disable no-useless-constructor -->
20412040
```js
20422041
const { Duplex } = require('stream');
20432042

@@ -2192,6 +2191,7 @@ output on the `Readable` side is not consumed.
21922191
* `flush` {Function} Implementation for the [`stream._flush()`][stream-_flush]
21932192
method.
21942193

2194+
<!-- eslint-disable no-useless-constructor -->
21952195
```js
21962196
const { Transform } = require('stream');
21972197

lib/perf_hooks.js

-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ function getMilestoneTimestamp(milestoneIdx) {
142142
}
143143

144144
class PerformanceNodeTiming {
145-
constructor() {}
146-
147145
get name() {
148146
return 'node';
149147
}

lib/v8.js

-4
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ class DefaultSerializer extends Serializer {
173173
}
174174

175175
class DefaultDeserializer extends Deserializer {
176-
constructor(buffer) {
177-
super(buffer);
178-
}
179-
180176
_readHostObject() {
181177
const typeIndex = this.readUint32();
182178
const ctor = arrayBufferViewTypes[typeIndex];

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

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ const assert = require('assert');
55
const stream = require('stream');
66

77
class MyWritable extends stream.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)