Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe5b29a

Browse files
authored
chore: remove unused errors in catchs, and reject parameters (#10354)
1 parent 683b7e6 commit fe5b29a

File tree

44 files changed

+64
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+64
-64
lines changed

e2e/__tests__/snapshot.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const initialTestData = fs.readFileSync(snapshotEscapeTestFile, 'utf8');
5959
const fileExists = (filePath: string) => {
6060
try {
6161
return fs.statSync(filePath).isFile();
62-
} catch (e) {}
62+
} catch {}
6363
return false;
6464
};
6565
const getSnapshotOfCopy = () => {

packages/expect/src/__tests__/matchers-toEqual.property.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('toEqual', () => {
2929
try {
3030
expect(a).toEqual(b);
3131
return true;
32-
} catch (err) {
32+
} catch {
3333
return false;
3434
}
3535
};

packages/expect/src/__tests__/matchers-toStrictEqual.property.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ describe('toStrictEqual', () => {
2020
try {
2121
expect(a).toStrictEqual(b);
2222
return true;
23-
} catch (err) {
23+
} catch {
2424
return false;
2525
}
2626
};
2727
const safeAssertDeepStrictEqual = (a, b) => {
2828
try {
2929
assert.deepStrictEqual(a, b);
3030
return true;
31-
} catch (err) {
31+
} catch {
3232
return false;
3333
}
3434
};

packages/expect/src/__tests__/spyMatchers.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ const createSpy = (fn: jest.Mock) => {
453453

454454
try {
455455
fn(true);
456-
} catch (error) {
456+
} catch {
457457
// ignore error
458458
}
459459

@@ -479,13 +479,13 @@ const createSpy = (fn: jest.Mock) => {
479479

480480
try {
481481
fn();
482-
} catch (error) {
482+
} catch {
483483
// ignore error
484484
}
485485

486486
try {
487487
fn();
488-
} catch (error) {
488+
} catch {
489489
// ignore error
490490
}
491491

@@ -501,7 +501,7 @@ const createSpy = (fn: jest.Mock) => {
501501

502502
try {
503503
fn();
504-
} catch (error) {
504+
} catch {
505505
// ignore error
506506
}
507507

@@ -652,7 +652,7 @@ const createSpy = (fn: jest.Mock) => {
652652

653653
try {
654654
fn(true);
655-
} catch (error) {
655+
} catch {
656656
// ignore error
657657
}
658658

@@ -679,7 +679,7 @@ const createSpy = (fn: jest.Mock) => {
679679

680680
try {
681681
fn(true);
682-
} catch (error) {
682+
} catch {
683683
// ignore error
684684
}
685685

@@ -886,7 +886,7 @@ const createSpy = (fn: jest.Mock) => {
886886

887887
try {
888888
fn();
889-
} catch (error) {
889+
} catch {
890890
// ignore error
891891
}
892892

@@ -908,7 +908,7 @@ const createSpy = (fn: jest.Mock) => {
908908

909909
try {
910910
fn();
911-
} catch (error) {
911+
} catch {
912912
// ignore error
913913
}
914914

packages/expect/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ const makeThrowingMatcher = (
338338

339339
return asyncResult
340340
.then(aResult => processResult(aResult, asyncError))
341-
.catch(error => handleError(error));
341+
.catch(handleError);
342342
} else {
343343
const syncResult = potentialResult as SyncExpectationResult;
344344

packages/jest-changed-files/src/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const adapter: SCMAdapter = {
9494
const result = await execa('git', options, {cwd});
9595

9696
return path.resolve(cwd, result.stdout);
97-
} catch (e) {
97+
} catch {
9898
return null;
9999
}
100100
},

packages/jest-changed-files/src/hg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const adapter: SCMAdapter = {
5151
const result = await execa('hg', ['root'], {cwd, env});
5252

5353
return result.stdout;
54-
} catch (e) {
54+
} catch {
5555
return null;
5656
}
5757
},

packages/jest-cli/src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const getProjectListFromCLIArgs = (
9797
if (!projects.length && process.platform === 'win32') {
9898
try {
9999
projects.push(tryRealpath(process.cwd()));
100-
} catch (err) {
100+
} catch {
101101
// do nothing, just catch error
102102
// process.binding('fs').realpath can throw, e.g. on mapped drives
103103
}

packages/jest-cli/src/init/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default async (
5353
projectPackageJson = JSON.parse(
5454
fs.readFileSync(projectPackageJsonPath, 'utf-8'),
5555
);
56-
} catch (error) {
56+
} catch {
5757
throw new MalformedPackageJsonError(projectPackageJsonPath);
5858
}
5959

packages/jest-config/src/__mocks__/read-pkg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function readPkg(file) {
2020
try {
2121
const json = JSON.parse(mockFile);
2222
return Promise.resolve(json);
23-
} catch (err) {
23+
} catch {
2424
return Promise.reject(`${file} is not valid JSON.`);
2525
}
2626
}

0 commit comments

Comments
 (0)