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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
18f2bf7f9b
commit
707b0a8534
@ -235,6 +235,7 @@ module.exports = {
|
|||||||
}],
|
}],
|
||||||
'no-useless-call': 'error',
|
'no-useless-call': 'error',
|
||||||
'no-useless-concat': 'error',
|
'no-useless-concat': 'error',
|
||||||
|
'no-useless-constructor': 'error',
|
||||||
'no-useless-escape': 'error',
|
'no-useless-escape': 'error',
|
||||||
'no-useless-return': 'error',
|
'no-useless-return': 'error',
|
||||||
'no-void': 'error',
|
'no-void': 'error',
|
||||||
|
@ -1450,6 +1450,7 @@ of the four basic stream classes (`stream.Writable`, `stream.Readable`,
|
|||||||
`stream.Duplex`, or `stream.Transform`), making sure they call the appropriate
|
`stream.Duplex`, or `stream.Transform`), making sure they call the appropriate
|
||||||
parent class constructor:
|
parent class constructor:
|
||||||
|
|
||||||
|
<!-- eslint-disable no-useless-constructor -->
|
||||||
```js
|
```js
|
||||||
const { Writable } = require('stream');
|
const { Writable } = require('stream');
|
||||||
|
|
||||||
@ -1547,6 +1548,7 @@ changes:
|
|||||||
* `autoDestroy` {boolean} Whether this stream should automatically call
|
* `autoDestroy` {boolean} Whether this stream should automatically call
|
||||||
`.destroy()` on itself after ending. **Default:** `false`.
|
`.destroy()` on itself after ending. **Default:** `false`.
|
||||||
|
|
||||||
|
<!-- eslint-disable no-useless-constructor -->
|
||||||
```js
|
```js
|
||||||
const { Writable } = require('stream');
|
const { Writable } = require('stream');
|
||||||
|
|
||||||
@ -1718,11 +1720,6 @@ required elements of a custom [`Writable`][] stream instance:
|
|||||||
const { Writable } = require('stream');
|
const { Writable } = require('stream');
|
||||||
|
|
||||||
class MyWritable extends Writable {
|
class MyWritable extends Writable {
|
||||||
constructor(options) {
|
|
||||||
super(options);
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
_write(chunk, encoding, callback) {
|
_write(chunk, encoding, callback) {
|
||||||
if (chunk.toString().indexOf('a') >= 0) {
|
if (chunk.toString().indexOf('a') >= 0) {
|
||||||
callback(new Error('chunk is invalid'));
|
callback(new Error('chunk is invalid'));
|
||||||
@ -1806,6 +1803,7 @@ changes:
|
|||||||
* `autoDestroy` {boolean} Whether this stream should automatically call
|
* `autoDestroy` {boolean} Whether this stream should automatically call
|
||||||
`.destroy()` on itself after ending. **Default:** `false`.
|
`.destroy()` on itself after ending. **Default:** `false`.
|
||||||
|
|
||||||
|
<!-- eslint-disable no-useless-constructor -->
|
||||||
```js
|
```js
|
||||||
const { Readable } = require('stream');
|
const { Readable } = require('stream');
|
||||||
|
|
||||||
@ -2064,6 +2062,7 @@ changes:
|
|||||||
* `writableHighWaterMark` {number} Sets `highWaterMark` for the writable side
|
* `writableHighWaterMark` {number} Sets `highWaterMark` for the writable side
|
||||||
of the stream. Has no effect if `highWaterMark` is provided.
|
of the stream. Has no effect if `highWaterMark` is provided.
|
||||||
|
|
||||||
|
<!-- eslint-disable no-useless-constructor -->
|
||||||
```js
|
```js
|
||||||
const { Duplex } = require('stream');
|
const { Duplex } = require('stream');
|
||||||
|
|
||||||
@ -2218,6 +2217,7 @@ output on the `Readable` side is not consumed.
|
|||||||
* `flush` {Function} Implementation for the [`stream._flush()`][stream-_flush]
|
* `flush` {Function} Implementation for the [`stream._flush()`][stream-_flush]
|
||||||
method.
|
method.
|
||||||
|
|
||||||
|
<!-- eslint-disable no-useless-constructor -->
|
||||||
```js
|
```js
|
||||||
const { Transform } = require('stream');
|
const { Transform } = require('stream');
|
||||||
|
|
||||||
|
@ -142,8 +142,6 @@ function getMilestoneTimestamp(milestoneIdx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PerformanceNodeTiming {
|
class PerformanceNodeTiming {
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
return 'node';
|
return 'node';
|
||||||
}
|
}
|
||||||
|
@ -172,10 +172,6 @@ class DefaultSerializer extends Serializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DefaultDeserializer extends Deserializer {
|
class DefaultDeserializer extends Deserializer {
|
||||||
constructor(buffer) {
|
|
||||||
super(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
_readHostObject() {
|
_readHostObject() {
|
||||||
const typeIndex = this.readUint32();
|
const typeIndex = this.readUint32();
|
||||||
const ctor = arrayBufferViewTypes[typeIndex];
|
const ctor = arrayBufferViewTypes[typeIndex];
|
||||||
|
@ -5,10 +5,6 @@ const assert = require('assert');
|
|||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
|
|
||||||
class MyWritable extends stream.Writable {
|
class MyWritable extends stream.Writable {
|
||||||
constructor(opt) {
|
|
||||||
super(opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
_write(chunk, encoding, callback) {
|
_write(chunk, encoding, callback) {
|
||||||
assert.notStrictEqual(chunk, null);
|
assert.notStrictEqual(chunk, null);
|
||||||
callback();
|
callback();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user