From 258eeaa5193b2837e4cd58e0493e7dba4010c194 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 b44c59caf30377..d06dff8fcde366 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -46,6 +46,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 96409a53677689..76679d3be4f6bf 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 29eb47cbe3956c..4f95d036921df9 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 4beb28351910ea..c43cb550828107 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -282,7 +282,6 @@ function enqueue(self, toEnqueue) { self.once('listening', clearQueue); } self._queue.push(toEnqueue); - return; } diff --git a/test/parallel/test-require-symlink.js b/test/parallel/test-require-symlink.js index 4e74606bedeed6..964f856829ac35 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 3e329a965f068c..c711783f141255 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.js @@ -222,7 +222,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' + @@ -495,9 +494,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; } } });