From fef2a54a4e17ada7d91615a50aa1e5adf1e83dd3 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 12 Mar 2019 14:39:06 -0400 Subject: [PATCH] tools: enable getter-return lint rule PR-URL: https://github.com/nodejs/node/pull/26615 Reviewed-By: Ruben Bridgewater Reviewed-By: Refael Ackermann Reviewed-By: Masashi Hirano Reviewed-By: James M Snell Reviewed-By: Yongsheng Zhang --- .eslintrc.js | 1 + lib/internal/http2/compat.js | 2 +- lib/net.js | 2 +- test/parallel/test-util-inspect.js | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d80507467bc041..3a51903e0dddc1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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' }, diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 551c9f1efa6bba..d866631fad0894 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -461,7 +461,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]; diff --git a/lib/net.js b/lib/net.js index d363878a929404..d6d5327f7c513a 100644 --- a/lib/net.js +++ b/lib/net.js @@ -516,7 +516,7 @@ Object.defineProperty(Socket.prototype, 'readyState', { Object.defineProperty(Socket.prototype, 'bufferSize', { - get: function() { + get: function() { // eslint-disable-line getter-return if (this._handle) { return this[kLastWriteQueueSize] + this.writableLength; } diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 5a626fe3a83b34..6c6d210dfe7fc6 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -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(