Unused error variables in catch block are not allowed (#24487)

This commit is contained in:
Alisa
2026-04-01 21:33:07 -07:00
committed by GitHub
parent 84936dc85d
commit 3344f6849c
92 changed files with 162 additions and 157 deletions
+1 -1
View File
@@ -176,7 +176,7 @@ export function getCheckpointInfoList(
checkpoint: file.replace('.json', ''),
});
}
} catch (_e) {
} catch {
// Ignore invalid JSON files
}
}
+2 -2
View File
@@ -66,7 +66,7 @@ export function parseAndFormatApiError(
if (isApiError(nestedError)) {
finalMessage = nestedError.error.message;
}
} catch (_e) {
} catch {
// It's not a nested JSON error, so we just use the message as is.
}
let text = `[API Error: ${finalMessage} (Status: ${parsedError.error.status})]`;
@@ -75,7 +75,7 @@ export function parseAndFormatApiError(
}
return text;
}
} catch (_e) {
} catch {
// Not a valid JSON, fall through and return the original message.
}
return `[API Error: ${error}]`;
+1 -1
View File
@@ -576,7 +576,7 @@ export async function fileExists(filePath: string): Promise<boolean> {
try {
await fsPromises.access(filePath, fs.constants.F_OK);
return true;
} catch (_: unknown) {
} catch {
return false;
}
}
@@ -80,7 +80,7 @@ export async function crawl(options: CrawlOptions): Promise<string[]> {
}
results = await api.crawl(options.crawlDirectory).withPromise();
} catch (_e) {
} catch {
// The directory probably doesn't exist.
return [];
}
+2 -2
View File
@@ -27,14 +27,14 @@ export const getPty = async (): Promise<PtyImplementation> => {
const module = await import(lydell);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
return { module, name: 'lydell-node-pty' };
} catch (_e) {
} catch {
try {
const nodePty = 'node-pty';
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const module = await import(nodePty);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
return { module, name: 'node-pty' };
} catch (_e2) {
} catch {
return null;
}
}
+2 -2
View File
@@ -37,7 +37,7 @@ export class GitIgnoreParser implements GitIgnoreFilter {
let content: string;
try {
content = fs.readFileSync(patternsFilePath, 'utf-8');
} catch (_error) {
} catch {
return ignore();
}
@@ -189,7 +189,7 @@ export class GitIgnoreParser implements GitIgnoreFilter {
// Extra patterns (like .geminiignore) have final precedence
return ig.add(this.processedExtraPatterns).ignores(normalizedPath);
} catch (_error) {
} catch {
return false;
}
}
+2 -2
View File
@@ -35,7 +35,7 @@ export function isGitRepository(directory: string): boolean {
}
return false;
} catch (_error) {
} catch {
// If any filesystem error occurs, assume not a git repo
return false;
}
@@ -67,7 +67,7 @@ export function findGitRoot(directory: string): string | null {
}
return null;
} catch (_error) {
} catch {
return null;
}
}
+5 -5
View File
@@ -159,7 +159,7 @@ export function parseGoogleApiError(error: unknown): GoogleApiError | null {
if (typeof errorObj === 'string') {
try {
errorObj = JSON.parse(sanitizeJsonString(errorObj));
} catch (_) {
} catch {
// Not a JSON string, can't parse.
return null;
}
@@ -200,7 +200,7 @@ export function parseGoogleApiError(error: unknown): GoogleApiError | null {
// The message is a JSON string, but not a nested error object.
break;
}
} catch (_error) {
} catch {
// It wasn't a JSON string, so we've drilled down as far as we can.
break;
}
@@ -284,7 +284,7 @@ function fromGaxiosError(errorObj: object): ErrorShape | undefined {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
data = JSON.parse(sanitizeJsonString(data));
} catch (_) {
} catch {
// Not a JSON string, can't parse.
}
}
@@ -334,7 +334,7 @@ function fromApiError(errorObj: object): ErrorShape | undefined {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
data = JSON.parse(sanitizeJsonString(data));
} catch (_) {
} catch {
// Not a JSON string, can't parse.
// Try one more fallback: look for the first '{' and last '}'
if (typeof data === 'string') {
@@ -346,7 +346,7 @@ function fromApiError(errorObj: object): ErrorShape | undefined {
data = JSON.parse(
sanitizeJsonString(data.substring(firstBrace, lastBrace + 1)),
);
} catch (__) {
} catch {
// Still failed
}
}
+1 -1
View File
@@ -60,7 +60,7 @@ export class IgnoreFileParser implements IgnoreFileFilter {
let content: string;
try {
content = fs.readFileSync(patternsFilePath, 'utf-8');
} catch (_error) {
} catch {
debugLogger.debug(
`Ignore file not found: ${patternsFilePath}, continue without it.`,
);
+1 -1
View File
@@ -368,7 +368,7 @@ export function resolveToRealPath(pathStr: string): string {
}
resolvedPath = decodeURIComponent(resolvedPath);
} catch (_e) {
} catch {
// Ignore error (e.g. malformed URI), keep path from previous step
}
+2 -2
View File
@@ -49,7 +49,7 @@ export async function killProcessGroup(options: KillOptions): Promise<void> {
// Invoke taskkill to ensure the entire tree is terminated and any orphaned descendant processes are reaped.
try {
await spawnAsync('taskkill', ['/pid', pid.toString(), '/f', '/t']);
} catch (_e) {
} catch {
// Ignore errors if the process tree is already dead
}
return;
@@ -72,7 +72,7 @@ export async function killProcessGroup(options: KillOptions): Promise<void> {
}
}
}
} catch (_e) {
} catch {
// Fallback to specific process kill if group kill fails or on error
if (!isExited()) {
if (pty) {
@@ -23,7 +23,7 @@ function validateUrl(url: string): void {
try {
parsedUrl = new URL(url);
} catch (_error) {
} catch {
throw new Error(`Invalid URL: ${url}`);
}
@@ -51,7 +51,7 @@ describe('execStreaming (Integration)', () => {
for await (const line of generator) {
lines.push(line);
}
} catch (_e) {
} catch {
// ignore
}
return lines;
+2 -2
View File
@@ -483,7 +483,7 @@ export function parseBashCommandDetails(
'Syntax Errors:',
syntaxErrors,
);
} catch (_e) {
} catch {
// Ignore query errors
} finally {
query?.delete();
@@ -945,7 +945,7 @@ export async function* execStreaming(
if (!finished && child.exitCode === null && !child.killed) {
try {
child.kill();
} catch (_e) {
} catch {
// ignore error if process is already dead
}
killedByGenerator = true;
+1 -1
View File
@@ -88,7 +88,7 @@ export function getSystemEncoding(): string | null {
locale = execSync('locale charmap', { encoding: 'utf8' })
.toString()
.trim();
} catch (_e) {
} catch {
debugLogger.warn('Failed to get locale charmap.');
return null;
}
+2 -2
View File
@@ -188,7 +188,7 @@ export class WorkspaceContext {
}
}
return false;
} catch (_error) {
} catch {
return false;
}
}
@@ -216,7 +216,7 @@ export class WorkspaceContext {
}
}
return false;
} catch (_error) {
} catch {
return false;
}
}