Skip to content

Commit

Permalink
[eslint] enable consistent-return
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 26, 2021
1 parent b03d4c8 commit fb4e3cf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Expand Up @@ -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"],
Expand Down
3 changes: 2 additions & 1 deletion bin/import-or-require.js
Expand Up @@ -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')) {
Expand Down
8 changes: 5 additions & 3 deletions lib/results.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion lib/test.js
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions test/promise_fail.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit fb4e3cf

Please sign in to comment.