Skip to content

Commit fb4e3cf

Browse files
committed
[eslint] enable consistent-return
1 parent b03d4c8 commit fb4e3cf

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"before": false,
1717
"after": true,
1818
}],
19+
"consistent-return": "error",
1920
"curly": ["error", "all"],
2021
"function-paren-newline": ["error", "multiline"],
2122
"function-call-argument-newline": ["error", "consistent"],

bin/import-or-require.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
const { extname: extnamePath } = require('path');
44
const getPackageType = require('get-package-type');
55

6-
module.exports = function (file) {
6+
// eslint-disable-next-line consistent-return
7+
module.exports = function importOrRequire(file) {
78
const ext = extnamePath(file);
89

910
if (ext === '.mjs' || (ext === '.js' && getPackageType.sync(file) === 'module')) {

lib/results.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ Results.prototype.createStream = function (opts) {
8686
while (t = getNextTest(self)) {
8787
t.run();
8888
if (!t.ended) {
89-
return t.once('end', function () { nextTick(next); });
89+
t.once('end', function () { nextTick(next); });
90+
return;
9091
}
9192
}
9293
self.emit('done');
@@ -215,11 +216,12 @@ function getNextTest(results) {
215216

216217
do {
217218
var t = $shift(results.tests);
218-
if (!t) { continue; }
219-
if (results._only === t) {
219+
if (t && results._only === t) {
220220
return t;
221221
}
222222
} while (results.tests.length !== 0);
223+
224+
return void undefined;
223225
}
224226

225227
function invalidYaml(str) {

lib/test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ function Test(name_, opts_, cb_) {
104104
Test.prototype.run = function run() {
105105
this.emit('prerun');
106106
if (!this._cb || this._skip) {
107-
return this._end();
107+
this._end();
108+
return;
108109
}
109110
if (this._timeout != null) {
110111
this.timeoutAfter(this._timeout);

test/promise_fail.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ tap.test('callback returning rejected promise should cause that test (and only t
1616
var rowsString = rows.toString('utf8');
1717

1818
if ((/^skip\n$/).test(rowsString)) {
19-
return tt.pass('the test file indicated it should be skipped');
19+
tt.pass('the test file indicated it should be skipped');
20+
return;
2021
}
2122

2223
var strippedString = stripFullStack(rowsString).filter(function (line) {
@@ -64,7 +65,8 @@ tap.test('subtest callback returning rejected promise should cause that subtest
6465
var rowsString = rows.toString('utf8');
6566

6667
if ((/^skip\n$/).test(rowsString)) {
67-
return tt.pass('the test file indicated it should be skipped');
68+
tt.pass('the test file indicated it should be skipped');
69+
return;
6870
}
6971

7072
var strippedString = stripFullStack(rowsString).filter(function (line) {

0 commit comments

Comments
 (0)