From b920c5d44b507790e19bd6dee429115db5a8678c 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-fs-symlink.js | 1 - test/parallel/test-require-symlink.js | 4 ++-- tools/doc/json.js | 4 ---- 7 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 77f82d8bca595c..462c4ae09bfa8e 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -45,6 +45,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 62194270e5d47b..ea60f2b0e51ddb 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 496267c44cce20..35755185eb9c4e 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1548,6 +1548,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 97c2de5fc47ef7..d38687ab6a7aa8 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -286,7 +286,6 @@ function enqueue(self, toEnqueue) { self.once('listening', clearQueue); } self._queue.push(toEnqueue); - return; } diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js index 9f3f0251e76b58..8200254031c0a6 100644 --- a/test/parallel/test-fs-symlink.js +++ b/test/parallel/test-fs-symlink.js @@ -14,7 +14,6 @@ if (common.isWindows) { exec('whoami /priv', function(err, o) { if (err || !o.includes('SeCreateSymbolicLinkPrivilege')) { common.skip('insufficient privileges'); - return; } }); } diff --git a/test/parallel/test-require-symlink.js b/test/parallel/test-require-symlink.js index faa26bfa41cd90..a44a0633e6e8a7 100644 --- a/test/parallel/test-require-symlink.js +++ b/test/parallel/test-require-symlink.js @@ -29,9 +29,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 2a966c83ec9388..9a05322fab6cdb 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' + @@ -499,9 +498,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; } } });