diff --git a/.eslintrc b/.eslintrc index 429f72f2..bb86a337 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,6 +16,7 @@ "before": false, "after": true, }], + "consistent-return": "error", "curly": ["error", "all"], "function-paren-newline": ["error", "multiline"], "function-call-argument-newline": ["error", "consistent"], diff --git a/bin/import-or-require.js b/bin/import-or-require.js index 8b72edd3..e2aa6b45 100644 --- a/bin/import-or-require.js +++ b/bin/import-or-require.js @@ -3,7 +3,8 @@ const { extname: extnamePath } = require('path'); const getPackageType = require('get-package-type'); -module.exports = function (file) { +// eslint-disable-next-line consistent-return +module.exports = function importOrRequire(file) { const ext = extnamePath(file); if (ext === '.mjs' || (ext === '.js' && getPackageType.sync(file) === 'module')) { diff --git a/lib/results.js b/lib/results.js index 92258b03..fc8b42e3 100644 --- a/lib/results.js +++ b/lib/results.js @@ -86,7 +86,8 @@ Results.prototype.createStream = function (opts) { while (t = getNextTest(self)) { t.run(); if (!t.ended) { - return t.once('end', function () { nextTick(next); }); + t.once('end', function () { nextTick(next); }); + return; } } self.emit('done'); @@ -215,11 +216,12 @@ function getNextTest(results) { do { var t = $shift(results.tests); - if (!t) { continue; } - if (results._only === t) { + if (t && results._only === t) { return t; } } while (results.tests.length !== 0); + + return void undefined; } function invalidYaml(str) { diff --git a/lib/test.js b/lib/test.js index 31275195..abdc2e10 100644 --- a/lib/test.js +++ b/lib/test.js @@ -104,7 +104,8 @@ function Test(name_, opts_, cb_) { Test.prototype.run = function run() { this.emit('prerun'); if (!this._cb || this._skip) { - return this._end(); + this._end(); + return; } if (this._timeout != null) { this.timeoutAfter(this._timeout); diff --git a/test/promise_fail.js b/test/promise_fail.js index a814917b..f45019da 100644 --- a/test/promise_fail.js +++ b/test/promise_fail.js @@ -16,7 +16,8 @@ tap.test('callback returning rejected promise should cause that test (and only t var rowsString = rows.toString('utf8'); if ((/^skip\n$/).test(rowsString)) { - return tt.pass('the test file indicated it should be skipped'); + tt.pass('the test file indicated it should be skipped'); + return; } var strippedString = stripFullStack(rowsString).filter(function (line) { @@ -64,7 +65,8 @@ tap.test('subtest callback returning rejected promise should cause that subtest var rowsString = rows.toString('utf8'); if ((/^skip\n$/).test(rowsString)) { - return tt.pass('the test file indicated it should be skipped'); + tt.pass('the test file indicated it should be skipped'); + return; } var strippedString = stripFullStack(rowsString).filter(function (line) {