Disallow unsafe returns. (#19767)

This commit is contained in:
Christian Gunderman
2026-02-21 01:12:56 +00:00
committed by GitHub
parent 09218572d0
commit dfd7721e69
26 changed files with 42 additions and 7 deletions

View File

@@ -348,6 +348,7 @@ export class IdeClient {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const parsedJson = JSON.parse(textPart.text);
if (parsedJson && typeof parsedJson.content === 'string') {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return parsedJson.content;
}
if (parsedJson && parsedJson.content === null) {

View File

@@ -123,6 +123,7 @@ export async function getConnectionConfigFromFile(
`gemini-ide-server-${pid}.json`,
);
const portFileContents = await fs.promises.readFile(portFile, 'utf8');
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(portFileContents);
} catch (_) {
// For newer extension versions, the file name matches the pattern
@@ -167,6 +168,7 @@ export async function getConnectionConfigFromFile(
}
const parsedContents = fileContents.map((content) => {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(content);
} catch (e) {
logger.debug('Failed to parse JSON from config file: ', e);
@@ -196,6 +198,7 @@ export async function getConnectionConfigFromFile(
if (fileIndex !== -1) {
logger.debug(`Selected IDE connection file: ${matchingFiles[fileIndex]}`);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return selected;
}
@@ -213,6 +216,7 @@ export async function getConnectionConfigFromFile(
`Selected IDE connection file (matched port from env): ${matchingFiles[fileIndex]}`,
);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return selected;
}
}
@@ -225,6 +229,7 @@ export async function getConnectionConfigFromFile(
`Selected first valid IDE connection file: ${matchingFiles[fileIndex]}`,
);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return selected;
}