Skip to content

Commit

Permalink
tools: enable no-useless-constructor lint rule
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and BethGriggs committed Feb 12, 2019
1 parent 8d953b7 commit 694ea00
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ module.exports = {
}],
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-constructor': 'error',
'no-useless-escape': 'error',
'no-useless-return': 'error',
'no-void': 'error',
Expand Down
10 changes: 5 additions & 5 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ of the four basic stream classes (`stream.Writable`, `stream.Readable`,
`stream.Duplex`, or `stream.Transform`), making sure they call the appropriate
parent class constructor:

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

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

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

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

class MyWritable extends Writable {
constructor(options) {
super(options);
// ...
}

_write(chunk, encoding, callback) {
if (chunk.toString().indexOf('a') >= 0) {
callback(new Error('chunk is invalid'));
Expand Down Expand Up @@ -1780,6 +1777,7 @@ constructor and implement the `readable._read()` method.
* `destroy` {Function} Implementation for the
[`stream._destroy()`][readable-_destroy] method.

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

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

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

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

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

Expand Down
2 changes: 0 additions & 2 deletions lib/perf_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ function getMilestoneTimestamp(milestoneIdx) {
}

class PerformanceNodeTiming {
constructor() {}

get name() {
return 'node';
}
Expand Down
4 changes: 0 additions & 4 deletions lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ class DefaultSerializer extends Serializer {
}

class DefaultDeserializer extends Deserializer {
constructor(buffer) {
super(buffer);
}

_readHostObject() {
const typeIndex = this.readUint32();
const ctor = arrayBufferViewTypes[typeIndex];
Expand Down
4 changes: 0 additions & 4 deletions test/parallel/test-stream-writable-null.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ const assert = require('assert');
const stream = require('stream');

class MyWritable extends stream.Writable {
constructor(opt) {
super(opt);
}

_write(chunk, encoding, callback) {
assert.notStrictEqual(chunk, null);
callback();
Expand Down

0 comments on commit 694ea00

Please sign in to comment.