From 7a4d383c7585204efdce2ee1891702c167e430a1 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 21 Apr 2017 18:50:52 -0400 Subject: [PATCH] tools: enable no-useless-return eslint rule PR-URL: https://github.com/nodejs/node/pull/12577 Reviewed-By: Vse Mozhet Byt Reviewed-By: Richard Lau Reviewed-By: James M Snell Reviewed-By: Teddy Katz Reviewed-By: Roman Reiss Reviewed-By: Luigi Pinca Reviewed-By: Refael Ackermann Reviewed-By: Gibson Fahnestock --- .eslintrc.yaml | 1 + doc/api/errors.md | 1 + doc/api/stream.md | 1 + lib/dgram.js | 1 - test/parallel/test-require-symlink.js | 4 ++-- tools/doc/json.js | 4 ---- 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 4efdc97608..e0896b1f52 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -50,6 +50,7 @@ rules: no-unused-labels: 2 no-useless-call: 2 no-useless-escape: 2 + no-useless-return: 2 no-void: 2 no-with: 2 diff --git a/doc/api/errors.md b/doc/api/errors.md index 0d02fe5870..9adf0c2088 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -64,6 +64,7 @@ Errors that occur within _Asynchronous APIs_ may be reported in multiple ways: argument is not `null` and is an instance of `Error`, then an error occurred that should be handled. + ```js const fs = require('fs'); fs.readFile('a file that does not exist', (err, data) => { diff --git a/doc/api/stream.md b/doc/api/stream.md index b750dd49b1..9e86955b97 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1566,6 +1566,7 @@ unexpected and inconsistent behavior depending on whether the stream is operating in flowing or paused mode. Using the `'error'` event ensures consistent and predictable handling of errors. + ```js const Readable = require('stream').Readable; diff --git a/lib/dgram.js b/lib/dgram.js index 0104d962b1..f2da1da1cc 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -307,7 +307,6 @@ function enqueue(self, toEnqueue) { self.once('listening', onListenSuccess); } self._queue.push(toEnqueue); - return; } diff --git a/test/parallel/test-require-symlink.js b/test/parallel/test-require-symlink.js index 4e74606bed..964f856829 100644 --- a/test/parallel/test-require-symlink.js +++ b/test/parallel/test-require-symlink.js @@ -30,9 +30,9 @@ if (common.isWindows) { if (err || !o.includes('SeCreateSymbolicLinkPrivilege')) { common.skip('insufficient privileges'); return; - } else { - test(); } + + test(); }); } else { test(); diff --git a/tools/doc/json.js b/tools/doc/json.js index dedfb1a84c..0e205ed7cb 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.js @@ -243,7 +243,6 @@ function processList(section) { current.options.push(n); current = n; } - return; } else if (type === 'list_item_end') { if (!current) { throw new Error('invalid list - end without current item\n' + @@ -516,9 +515,6 @@ function finishSection(section, parent) { parent[k] = parent[k].concat(section[k]); } else if (!parent[k]) { parent[k] = section[k]; - } else { - // parent already has, and it's not an array. - return; } } });