Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: enable getter-return lint rule #26615

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module.exports = {
'func-call-spacing': 'error',
'func-name-matching': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'getter-return': 'error',
'indent': ['error', 2, {
ArrayExpression: 'first',
CallExpression: { arguments: 'first' },
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class Http2ServerResponse extends Stream {
// This is compatible with http1 which removes socket reference
// only from ServerResponse but not IncomingMessage
if (this[kState].closed)
return;
return undefined;

const stream = this[kStream];
const proxySocket = stream[kProxySocket];
Expand Down
2 changes: 1 addition & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ Object.defineProperty(Socket.prototype, 'readyState', {


Object.defineProperty(Socket.prototype, 'bufferSize', {
get: function() {
get: function() { // eslint-disable-line getter-return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, eslint-disable-line getter-return is unnecessary if this function returns undefined explicitly.

  get: function() {
    if (this._handle) {
      return this[kLastWriteQueueSize] + this.writableLength;
    }
    return undefined;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shisama in this case I thought it would be simplest to just add the comment. If you feel strongly about it, I can add the return undefined; instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjihrig No, I am not particular about it. This is just a proposal. Thanks for your reply :)

if (this._handle) {
return this[kLastWriteQueueSize] + this.writableLength;
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ assert.strictEqual(
// Dynamic properties.
{
assert.strictEqual(
util.inspect({ get readonly() {} }),
util.inspect({ get readonly() { return 1; } }),
'{ readonly: [Getter] }');

assert.strictEqual(
util.inspect({ get readwrite() {}, set readwrite(val) {} }),
util.inspect({ get readwrite() { return 1; }, set readwrite(val) {} }),
'{ readwrite: [Getter/Setter] }');

assert.strictEqual(
Expand Down