Skip to content

Commit bd94e72

Browse files
committed
Remove unused catch vars
1 parent 3b28356 commit bd94e72

File tree

9 files changed

+16
-15
lines changed

9 files changed

+16
-15
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export default tseslint.config(
131131
// Ignore: (solely underscores | starting with exactly one underscore)
132132
argsIgnorePattern: "^(_+$|_[^_])",
133133
varsIgnorePattern: "^(_+$|_[^_])",
134+
// Not setting an ignore pattern for caught errors; those can always be safely removed.
134135
},
135136
],
136137
"@typescript-eslint/no-inferrable-types": "off",

scripts/failed-tests.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class FailedTestsReporter extends Mocha.reporters.Base {
4545
try {
4646
reporter = require(reporterOptions.reporter);
4747
}
48-
catch (_) {
48+
catch {
4949
reporter = require(path.resolve(process.cwd(), reporterOptions.reporter));
5050
}
5151
}

scripts/find-unused-diganostic-messages.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ startOfDiags.split(EOL).forEach(line => {
1818
execSync(`grep -rnw 'src' -e 'Diagnostics.${diagName}'`).toString();
1919
process.stdout.write(".");
2020
}
21-
catch (error) {
21+
catch {
2222
missingNames.push(diagName);
2323
process.stdout.write("x");
2424
}

src/compiler/sys.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ export let sys: System = (() => {
17921792
try {
17931793
buffer = _fs.readFileSync(fileName);
17941794
}
1795-
catch (e) {
1795+
catch {
17961796
return undefined;
17971797
}
17981798
let len = buffer.length;
@@ -1863,7 +1863,7 @@ export let sys: System = (() => {
18631863
continue;
18641864
}
18651865
}
1866-
catch (e) {
1866+
catch {
18671867
continue;
18681868
}
18691869
}
@@ -1882,7 +1882,7 @@ export let sys: System = (() => {
18821882
directories.sort();
18831883
return { files, directories };
18841884
}
1885-
catch (e) {
1885+
catch {
18861886
return emptyFileSystemEntries;
18871887
}
18881888
}
@@ -1911,7 +1911,7 @@ export let sys: System = (() => {
19111911
return false;
19121912
}
19131913
}
1914-
catch (e) {
1914+
catch {
19151915
return false;
19161916
}
19171917
finally {
@@ -1952,7 +1952,7 @@ export let sys: System = (() => {
19521952
try {
19531953
return statSync(path)?.mtime;
19541954
}
1955-
catch (e) {
1955+
catch {
19561956
return undefined;
19571957
}
19581958
finally {
@@ -1964,7 +1964,7 @@ export let sys: System = (() => {
19641964
try {
19651965
_fs.utimesSync(path, time, time);
19661966
}
1967-
catch (e) {
1967+
catch {
19681968
return;
19691969
}
19701970
}
@@ -1973,7 +1973,7 @@ export let sys: System = (() => {
19731973
try {
19741974
return _fs.unlinkSync(path);
19751975
}
1976-
catch (e) {
1976+
catch {
19771977
return;
19781978
}
19791979
}

src/compiler/utilitiesPublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ export function validateLocaleAndSetLanguage(
723723
try {
724724
fileContents = sys.readFile(filePath);
725725
}
726-
catch (e) {
726+
catch {
727727
if (errors) {
728728
errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
729729
}

src/compiler/watchUtilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export function createCachedDirectoryStructureHost(host: DirectoryStructureHost,
198198
try {
199199
return createCachedFileSystemEntries(rootDir, rootDirPath);
200200
}
201-
catch (_e) {
201+
catch {
202202
// If there is exception to read directories, dont cache the result and direct the calls to host
203203
Debug.assert(!cachedReadDirectoryResult.has(ensureTrailingDirectorySeparator(rootDirPath)));
204204
return undefined;

src/harness/harnessUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function readTestFile(path: string) {
4141
try {
4242
content = Harness.IO.readFile(Harness.userSpecifiedRoot + path);
4343
}
44-
catch (err) {
44+
catch {
4545
return undefined;
4646
}
4747

src/tsserver/nodeServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export function initializeNodeSystem(): StartInput {
124124
try {
125125
this.fd = fs.openSync(this.logFilename, "w");
126126
}
127-
catch (_) {
127+
catch {
128128
// swallow the error and keep logging disabled if file cannot be opened
129129
}
130130
}
@@ -280,7 +280,7 @@ export function initializeNodeSystem(): StartInput {
280280
const factory = require("./cancellationToken.js");
281281
cancellationToken = factory(sys.args);
282282
}
283-
catch (e) {
283+
catch {
284284
cancellationToken = ts.server.nullCancellationToken;
285285
}
286286

src/typingsInstaller/nodeTypingsInstaller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FileLog implements ts.server.typingsInstaller.Log {
2828
try {
2929
fs.appendFileSync(this.logFile, `[${ts.server.nowString()}] ${text}${sys.newLine}`);
3030
}
31-
catch (e) {
31+
catch {
3232
this.logFile = undefined;
3333
}
3434
};

0 commit comments

Comments
 (0)