Skip to content

Commit 7f2ce6e

Browse files
cjihrigcodebytere
authored andcommitted
test: remove unused catch bindings
PR-URL: #24079 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Wyatt Preul <[email protected]>
1 parent bbd38ea commit 7f2ce6e

30 files changed

+57
-57
lines changed

test/common/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function canCreateSymLink() {
371371
try {
372372
const output = execSync(`${whoamiPath} /priv`, { timout: 1000 });
373373
return output.includes('SeCreateSymbolicLinkPrivilege');
374-
} catch (e) {
374+
} catch {
375375
return false;
376376
}
377377
}
@@ -455,7 +455,7 @@ function isAlive(pid) {
455455
try {
456456
process.kill(pid, 'SIGCONT');
457457
return true;
458-
} catch (e) {
458+
} catch {
459459
return false;
460460
}
461461
}
@@ -664,7 +664,7 @@ function getTTYfd() {
664664
if (ttyFd === undefined) {
665665
try {
666666
return fs.openSync('/dev/tty');
667-
} catch (e) {
667+
} catch {
668668
// There aren't any tty fd's available to use.
669669
return -1;
670670
}
@@ -678,7 +678,7 @@ function runWithInvalidFD(func) {
678678
// be an valid one.
679679
try {
680680
while (fs.fstatSync(fd--) && fd > 0);
681-
} catch (e) {
681+
} catch {
682682
return func(fd);
683683
}
684684

test/doctool/test-doctool-html.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const common = require('../common');
44
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
55
try {
66
require('../../tools/node_modules/eslint/node_modules/js-yaml');
7-
} catch (e) {
7+
} catch {
88
common.skip('missing js-yaml (eslint not present)');
99
}
1010

test/doctool/test-doctool-json.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const common = require('../common');
44
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
55
try {
66
require('../../tools/node_modules/eslint/node_modules/js-yaml');
7-
} catch (e) {
7+
} catch {
88
common.skip('missing js-yaml (eslint not present)');
99
}
1010

test/fixtures/catch-stdout-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
function write() {
2323
try {
2424
process.stdout.write('Hello, world\n');
25-
} catch (ex) {
25+
} catch {
2626
throw new Error('this should never happen');
2727
}
2828
setImmediate(function() {

test/internet/test-dgram-broadcast-multi-process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ if (process.argv[2] !== 'child') {
182182
const buf = messages[i++];
183183

184184
if (!buf) {
185-
try { sendSocket.close(); } catch (e) {}
185+
try { sendSocket.close(); } catch {}
186186
return;
187187
}
188188

test/internet/test-dgram-multicast-multi-process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ if (process.argv[2] !== 'child') {
170170
const buf = messages[i++];
171171

172172
if (!buf) {
173-
try { sendSocket.close(); } catch (e) {}
173+
try { sendSocket.close(); } catch {}
174174
return;
175175
}
176176

test/known_issues/test-url-parse-conformance.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ tests.forEach((test) => {
4040
assert.strictEqual(test.pathname, parsed.pathname || '/');
4141
assert.strictEqual(test.search, parsed.search || '');
4242
assert.strictEqual(test.hash, parsed.hash || '');
43-
} catch (err) {
43+
} catch {
4444
// For now, we're just interested in the number of failures.
4545
failed++;
4646
}
4747
}
48-
} catch (err) {
48+
} catch {
4949
// If Parse failed and it wasn't supposed to, treat it as a failure.
5050
if (!test.failure)
5151
failed++;

test/message/vm_dont_display_runtime_error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ try {
3030
filename: 'test.vm',
3131
displayErrors: false
3232
});
33-
} catch (e) {}
33+
} catch {}
3434

3535
console.error('middle');
3636

test/message/vm_dont_display_syntax_error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ try {
3030
filename: 'test.vm',
3131
displayErrors: false
3232
});
33-
} catch (e) {}
33+
} catch {}
3434

3535
console.error('middle');
3636

test/parallel/test-assert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ assert.throws(
166166
},
167167
Array
168168
);
169-
} catch (e) {
169+
} catch {
170170
threw = true;
171171
}
172172
assert.ok(threw, 'wrong constructor validation');

test/parallel/test-crypto-cipher-decipher.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ testCipher2(Buffer.from('0123456789abcdef'));
159159
// not assert. See https://github.com/nodejs/node-v0.x-archive/issues/4886.
160160
{
161161
const c = crypto.createCipher('aes-256-cbc', 'secret');
162-
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
163-
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
164-
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
162+
try { c.final('xxx'); } catch { /* Ignore. */ }
163+
try { c.final('xxx'); } catch { /* Ignore. */ }
164+
try { c.final('xxx'); } catch { /* Ignore. */ }
165165
const d = crypto.createDecipher('aes-256-cbc', 'secret');
166-
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
167-
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
168-
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
166+
try { d.final('xxx'); } catch { /* Ignore. */ }
167+
try { d.final('xxx'); } catch { /* Ignore. */ }
168+
try { d.final('xxx'); } catch { /* Ignore. */ }
169169
}
170170

171171
// Regression test for https://github.com/nodejs/node-v0.x-archive/issues/5482:

test/parallel/test-file-write-stream2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ process.on('exit', function() {
5656
function removeTestFile() {
5757
try {
5858
fs.unlinkSync(filepath);
59-
} catch (e) {}
59+
} catch {}
6060
}
6161

6262

test/parallel/test-fs-realpath-pipe.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ for (const code of [
2222
if (require('fs').realpathSync('/dev/stdin')) {
2323
process.exit(2);
2424
}
25-
} catch (e) {
25+
} catch {
2626
process.exit(1);
2727
}`
2828
]) {

test/parallel/test-fs-realpath.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function test_simple_relative_symlink(realpath, realpathSync, callback) {
100100
[
101101
[entry, `../${path.basename(tmpDir)}/cycles/root.js`]
102102
].forEach(function(t) {
103-
try { fs.unlinkSync(t[0]); } catch (e) {}
103+
try { fs.unlinkSync(t[0]); } catch {}
104104
console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file');
105105
fs.symlinkSync(t[1], t[0], 'file');
106106
unlink.push(t[0]);
@@ -126,7 +126,7 @@ function test_simple_absolute_symlink(realpath, realpathSync, callback) {
126126
[
127127
[entry, expected]
128128
].forEach(function(t) {
129-
try { fs.unlinkSync(t[0]); } catch (e) {}
129+
try { fs.unlinkSync(t[0]); } catch {}
130130
console.error('fs.symlinkSync(%j, %j, %j)', t[1], t[0], type);
131131
fs.symlinkSync(t[1], t[0], type);
132132
unlink.push(t[0]);
@@ -151,13 +151,13 @@ function test_deep_relative_file_symlink(realpath, realpathSync, callback) {
151151
expected);
152152
const linkPath1 = path.join(targetsAbsDir,
153153
'nested-index', 'one', 'symlink1.js');
154-
try { fs.unlinkSync(linkPath1); } catch (e) {}
154+
try { fs.unlinkSync(linkPath1); } catch {}
155155
fs.symlinkSync(linkData1, linkPath1, 'file');
156156

157157
const linkData2 = '../one/symlink1.js';
158158
const entry = path.join(targetsAbsDir,
159159
'nested-index', 'two', 'symlink1-b.js');
160-
try { fs.unlinkSync(entry); } catch (e) {}
160+
try { fs.unlinkSync(entry); } catch {}
161161
fs.symlinkSync(linkData2, entry, 'file');
162162
unlink.push(linkPath1);
163163
unlink.push(entry);
@@ -178,13 +178,13 @@ function test_deep_relative_dir_symlink(realpath, realpathSync, callback) {
178178
const path1b = path.join(targetsAbsDir, 'nested-index', 'one');
179179
const linkPath1b = path.join(path1b, 'symlink1-dir');
180180
const linkData1b = path.relative(path1b, expected);
181-
try { fs.unlinkSync(linkPath1b); } catch (e) {}
181+
try { fs.unlinkSync(linkPath1b); } catch {}
182182
fs.symlinkSync(linkData1b, linkPath1b, 'dir');
183183

184184
const linkData2b = '../one/symlink1-dir';
185185
const entry = path.join(targetsAbsDir,
186186
'nested-index', 'two', 'symlink12-dir');
187-
try { fs.unlinkSync(entry); } catch (e) {}
187+
try { fs.unlinkSync(entry); } catch {}
188188
fs.symlinkSync(linkData2b, entry, 'dir');
189189
unlink.push(linkPath1b);
190190
unlink.push(entry);
@@ -208,7 +208,7 @@ function test_cyclic_link_protection(realpath, realpathSync, callback) {
208208
[path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
209209
[path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
210210
].forEach(function(t) {
211-
try { fs.unlinkSync(t[0]); } catch (e) {}
211+
try { fs.unlinkSync(t[0]); } catch {}
212212
fs.symlinkSync(t[1], t[0], 'dir');
213213
unlink.push(t[0]);
214214
});
@@ -235,7 +235,7 @@ function test_cyclic_link_overprotection(realpath, realpathSync, callback) {
235235
const link = `${folder}/cycles`;
236236
let testPath = cycles;
237237
testPath += '/folder/cycles'.repeat(10);
238-
try { fs.unlinkSync(link); } catch (ex) {}
238+
try { fs.unlinkSync(link); } catch {}
239239
fs.symlinkSync(cycles, link, 'dir');
240240
unlink.push(link);
241241
assertEqualPath(realpathSync(testPath), path.resolve(expected));
@@ -263,7 +263,7 @@ function test_relative_input_cwd(realpath, realpathSync, callback) {
263263
].forEach(function(t) {
264264
const fn = t[0];
265265
console.error('fn=%j', fn);
266-
try { fs.unlinkSync(fn); } catch (e) {}
266+
try { fs.unlinkSync(fn); } catch {}
267267
const b = path.basename(t[1]);
268268
const type = (b === 'root.js' ? 'file' : 'dir');
269269
console.log('fs.symlinkSync(%j, %j, %j)', t[1], fn, type);
@@ -302,8 +302,8 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
302302
$tmpDir/targets/cycles/root.js (hard)
303303
*/
304304
const entry = tmp('node-test-realpath-f1');
305-
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch (e) {}
306-
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch (e) {}
305+
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch {}
306+
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch {}
307307
fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
308308
try {
309309
[
@@ -318,7 +318,7 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
318318
[`${targetsAbsDir}/nested-index/two/realpath-c`,
319319
`${tmpDir}/cycles/root.js`]
320320
].forEach(function(t) {
321-
try { fs.unlinkSync(t[0]); } catch (e) {}
321+
try { fs.unlinkSync(t[0]); } catch {}
322322
fs.symlinkSync(t[1], t[0]);
323323
unlink.push(t[0]);
324324
});
@@ -429,14 +429,14 @@ function test_abs_with_kids(realpath, realpathSync, cb) {
429429
['/a/b/c/x.txt',
430430
'/a/link'
431431
].forEach(function(file) {
432-
try { fs.unlinkSync(root + file); } catch (ex) {}
432+
try { fs.unlinkSync(root + file); } catch {}
433433
});
434434
['/a/b/c',
435435
'/a/b',
436436
'/a',
437437
''
438438
].forEach(function(folder) {
439-
try { fs.rmdirSync(root + folder); } catch (ex) {}
439+
try { fs.rmdirSync(root + folder); } catch {}
440440
});
441441
}
442442
function setup() {

test/parallel/test-listen-fd-detached-inherit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function test() {
6969
process.kill(child.pid, 'SIGKILL');
7070
try {
7171
parent.kill();
72-
} catch (e) {}
72+
} catch {}
7373

7474
assert.strictEqual(s, 'hello from child\n');
7575
assert.strictEqual(res.statusCode, 200);

test/parallel/test-listen-fd-detached.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function test() {
6969
process.kill(child.pid, 'SIGKILL');
7070
try {
7171
parent.kill();
72-
} catch (e) {}
72+
} catch {}
7373

7474
assert.strictEqual(s, 'hello from child\n');
7575
assert.strictEqual(res.statusCode, 200);

test/parallel/test-listen-fd-ebadf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let invalidFd = 2;
3434
// Get first known bad file descriptor.
3535
try {
3636
while (fs.fstatSync(++invalidFd));
37-
} catch (e) {
37+
} catch {
3838
// do nothing; we now have an invalid fd
3939
}
4040

test/parallel/test-module-loading-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if (common.isWindows) {
4545
try {
4646
// If MUI != 'en' we'll ignore the content of the message
4747
localeOk = execSync(powerShellFindMUI).toString('utf8').trim() === 'en';
48-
} catch (_) {
48+
} catch {
4949
// It's only a best effort try to find the MUI
5050
}
5151
}

test/parallel/test-promises-unhandled-rejections.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
681681
setTimeout(function() {
682682
try {
683683
p.catch(function() {});
684-
} catch (e) {
684+
} catch {
685685
done(new Error('fail'));
686686
}
687687
}, 1);

test/parallel/test-repl-syntax-error-handling.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function child() {
6363
let caught;
6464
try {
6565
vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false });
66-
} catch (er) {
66+
} catch {
6767
caught = true;
6868
}
6969
assert(caught);

test/parallel/test-require-deps-deprecation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ common.expectWarning('DeprecationWarning', deprecatedModules.map((m) => {
3434
for (const m of deprecatedModules) {
3535
try {
3636
require(m);
37-
} catch (err) {}
37+
} catch {}
3838
}
3939

4040
// Instead of checking require, check that resolve isn't pointing toward a

test/parallel/test-stdout-close-catch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ child.stderr.on('data', function(c) {
2727
child.on('close', common.mustCall(function(code) {
2828
try {
2929
output = JSON.parse(output);
30-
} catch (er) {
30+
} catch {
3131
console.error(output);
3232
process.exit(1);
3333
}

test/parallel/test-stdout-to-file.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function test(size, useBuffer, cb) {
1919

2020
try {
2121
fs.unlinkSync(tmpFile);
22-
} catch (e) {}
22+
} catch {}
2323

2424
console.log(`${size} chars to ${tmpFile}...`);
2525

test/parallel/test-vm-low-stack-space.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const vm = require('vm');
66
function a() {
77
try {
88
return a();
9-
} catch (e) {
9+
} catch {
1010
// Throw an exception as near to the recursion-based RangeError as possible.
1111
return vm.runInThisContext('() => 42')();
1212
}
@@ -17,7 +17,7 @@ assert.strictEqual(a(), 42);
1717
function b() {
1818
try {
1919
return b();
20-
} catch (e) {
20+
} catch {
2121
// This writes a lot of noise to stderr, but it still works.
2222
return vm.runInNewContext('() => 42')();
2323
}

test/parallel/test-vm-module-errors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function checkModuleState() {
9797
const m = new SourceTextModule('import "foo";');
9898
try {
9999
await m.link(common.mustCall(() => ({})));
100-
} catch (err) {
100+
} catch {
101101
assert.strictEqual(m.linkingStatus, 'errored');
102102
m.instantiate();
103103
}
@@ -218,7 +218,7 @@ async function checkLinking() {
218218
const erroredModule = new SourceTextModule('import "foo";');
219219
try {
220220
await erroredModule.link(common.mustCall(() => ({})));
221-
} catch (err) {
221+
} catch {
222222
// ignored
223223
} finally {
224224
assert.strictEqual(erroredModule.linkingStatus, 'errored');

0 commit comments

Comments
 (0)