Skip to content

Commit

Permalink
[eslint] enable no-shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 24, 2021
1 parent e9b75e1 commit f0756f3
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 71 deletions.
5 changes: 5 additions & 0 deletions .eslintrc
Expand Up @@ -25,6 +25,11 @@
"named": "never",
}],
"no-extra-semi": "error",
"no-shadow": ["error", {
"builtinGlobals": false,
"hoist": "functions",
"allow": []
}],
"no-undef": "error",
"no-useless-escape": "error",
"object-curly-newline": ["error", {
Expand Down
10 changes: 5 additions & 5 deletions bin/tape
Expand Up @@ -47,13 +47,13 @@ if (typeof opts.ignore === 'string') {
var files = opts._.reduce(function (result, arg) {
// If glob does not match, `files` will be an empty array.
// Note: `glob.sync` may throw an error and crash the node process.
var files = glob.sync(arg);
var globFiles = glob.sync(arg);

if (!Array.isArray(files)) {
if (!Array.isArray(globFiles)) {
throw new TypeError('unknown error: glob.sync("' + arg + '") did not return an array or throw. Please report this.');
}

return result.concat(files);
return result.concat(globFiles);
}, []).filter(function (file) {
return !matcher || !matcher.shouldIgnore(file);
}).map(function (file) {
Expand All @@ -75,13 +75,13 @@ function importFiles(hasSupport) {

tape.wait();

var promise = files.reduce(function (promise, file) {
var filesPromise = files.reduce(function (promise, file) {
return promise ? promise.then(function () {
return importOrRequire(file);
}) : importOrRequire(file);
}, null);

return promise ? promise.then(function () { tape.run(); }) : tape.run();
return filesPromise ? filesPromise.then(function () { tape.run(); }) : tape.run();
}

// vim: ft=javascript
6 changes: 3 additions & 3 deletions lib/test.js
Expand Up @@ -423,19 +423,19 @@ Test.prototype.skip = function skip(msg, extra) {
});
};

function assert(value, msg, extra) {
var testAssert = function assert(value, msg, extra) {
this._assert(value, {
message: defined(msg, 'should be truthy'),
operator: 'ok',
expected: true,
actual: value,
extra: extra
});
}
};
Test.prototype.ok
= Test.prototype['true']
= Test.prototype.assert
= assert;
= testAssert;

function notOK(value, msg, extra) {
this._assert(!value, {
Expand Down
4 changes: 2 additions & 2 deletions test/async-await/async5.js
Expand Up @@ -33,8 +33,8 @@ test('async5', async function myTest(t) {
port: server.address().port,
path: '/',
method: 'GET'
}, function (res) {
cb(null, res);
}, function (resp) {
cb(null, resp);
});
req.end();
})();
Expand Down
30 changes: 15 additions & 15 deletions test/child_ordering.js
Expand Up @@ -5,10 +5,10 @@ var test = require('../');
var childRan = false;

test('parent', function (t) {
t.test('child', function (t) {
t.test('child', function (st) {
childRan = true;
t.pass('child ran');
t.end();
st.pass('child ran');
st.end();
});
t.end();
});
Expand All @@ -24,22 +24,22 @@ var grandChildRan = false;
test('grandparent', function (t) {
t.ok(!grandParentRan, 'grand parent ran twice');
grandParentRan = true;
t.test('parent', function (t) {
t.ok(!parentRan, 'parent ran twice');
t.test('parent', function (st) {
st.ok(!parentRan, 'parent ran twice');
parentRan = true;
t.test('grandchild', function (t) {
t.ok(!grandChildRan, 'grand child ran twice');
st.test('grandchild', function (s2t) {
s2t.ok(!grandChildRan, 'grand child ran twice');
grandChildRan = true;
t.pass('grand child ran');
t.end();
s2t.pass('grand child ran');
s2t.end();
});
t.pass('parent ran');
t.end();
st.pass('parent ran');
st.end();
});
t.test('other parent', function (t) {
t.ok(parentRan, 'first parent runs before second parent');
t.ok(grandChildRan, 'grandchild runs before second parent');
t.end();
t.test('other parent', function (st) {
st.ok(parentRan, 'first parent runs before second parent');
st.ok(grandChildRan, 'grandchild runs before second parent');
st.end();
});
t.pass('grandparent ran');
t.end();
Expand Down
10 changes: 5 additions & 5 deletions test/nested2.js
Expand Up @@ -4,17 +4,17 @@ var test = require('../');

test(function (t) {
var i = 0;
t.test('setup', function (t) {
t.test('setup', function (st) {
process.nextTick(function () {
t.equal(i, 0, 'called once');
st.equal(i, 0, 'called once');
i++;
t.end();
st.end();
});
});


t.test('teardown', function (t) {
t.end();
t.test('teardown', function (st) {
st.end();
});

t.end();
Expand Down
18 changes: 9 additions & 9 deletions test/objectMode.js
Expand Up @@ -24,21 +24,21 @@ tap.test('object results', function (assert) {

assert.equal(objects.length, 13);

forEach(objects, function (obj) {
if (obj.type === 'assert') {
forEach(objects, function (object) {
if (object.type === 'assert') {
asserts++;
} else if (obj.type === 'test') {
testIds.push(obj.id);
} else if (object.type === 'test') {
testIds.push(object.id);

if (obj.skip) {
if (object.skip) {
skips++;
} else if (obj.todo) {
} else if (object.todo) {
todos++;
}
} else if (obj.type === 'end') {
endIds.push(obj.text);
} else if (object.type === 'end') {
endIds.push(object.text);
// test object should exist
assert.notEqual(testIds.indexOf(obj.test), -1);
assert.notEqual(testIds.indexOf(object.test), -1);
}
});

Expand Down
8 changes: 4 additions & 4 deletions test/promises/subTests.js
Expand Up @@ -4,14 +4,14 @@ var test = require('../../');

if (typeof Promise === 'function' && typeof Promise.resolve === 'function') {
test('promise', function (t) {
t.test('sub test that should fail', function (t) {
t.test('sub test that should fail', function () {
return new Promise(function (resolve, reject) {
reject(new Error('rejection message'));
});
});
t.test('sub test that should pass', function (t) {
t.plan(1);
t.ok(true);
t.test('sub test that should pass', function (st) {
st.plan(1);
st.ok(true);
});
});
} else {
Expand Down
6 changes: 3 additions & 3 deletions test/skip.js
Expand Up @@ -44,9 +44,9 @@ test.skip('skip this too', function (t) {

test('skip subtest', function (t) {
ran++;
t.test('skip this', { skip: true }, function (t) {
t.fail('this should not even run');
t.end();
t.test('skip this', { skip: true }, function (st) {
st.fail('this should not even run');
st.end();
});
t.end();
});
Expand Down
12 changes: 6 additions & 6 deletions test/subcount.js
Expand Up @@ -4,13 +4,13 @@ var test = require('../');

test('parent test', function (t) {
t.plan(2);
t.test('first child', function (t) {
t.plan(1);
t.pass('pass first child');
t.test('first child', function (st) {
st.plan(1);
st.pass('pass first child');
});

t.test(function (t) {
t.plan(1);
t.pass('pass second child');
t.test(function (st) {
st.plan(1);
st.pass('pass second child');
});
});
14 changes: 7 additions & 7 deletions test/subtest_plan.js
Expand Up @@ -9,15 +9,15 @@ test('parent', function (t) {

t.pass('assertion in parent');

t.test('first child', function (t) {
t.plan(1);
t.pass('pass first child');
t.test('first child', function (st) {
st.plan(1);
st.pass('pass first child');
firstChildRan = true;
});

t.test('second child', function (t) {
t.plan(2);
t.ok(firstChildRan, 'first child ran first');
t.pass('pass second child');
t.test('second child', function (st) {
st.plan(2);
st.ok(firstChildRan, 'first child ran first');
st.pass('pass second child');
});
});
12 changes: 0 additions & 12 deletions test/throws.js
Expand Up @@ -8,18 +8,6 @@ var assign = require('object.assign');

var stripFullStack = require('./common').stripFullStack;

function fn() {
throw new TypeError('RegExp');
}

function getNonFunctionMessage(fn) {
try {
fn();
} catch (e) {
return e.message;
}
}

var getter = function () { return 'message'; };
var messageGetterError = Object.defineProperty(
{ custom: 'error' },
Expand Down

0 comments on commit f0756f3

Please sign in to comment.