Disallow floating promises. (#14605)

This commit is contained in:
Christian Gunderman
2025-12-05 16:12:49 -08:00
committed by GitHub
parent 3cf44acc08
commit 025e450ac2
57 changed files with 128 additions and 4 deletions
@@ -40,6 +40,7 @@ function addShellCommandToGeminiHistory(
? resultText.substring(0, MAX_OUTPUT_LENGTH) + '\n... (truncated)'
: resultText;
// eslint-disable-next-line @typescript-eslint/no-floating-promises
geminiClient.addHistory({
role: 'user',
parts: [
@@ -350,6 +351,7 @@ export const useShellCommandProcessor = (
};
const execPromise = new Promise<void>((resolve) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
executeCommand(resolve);
});
@@ -258,6 +258,7 @@ export const useSlashCommandProcessor = (
reloadCommands();
};
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
const ideClient = await IdeClient.getInstance();
ideClient.addStatusChangeListener(listener);
@@ -278,6 +279,7 @@ export const useSlashCommandProcessor = (
appEvents.on('extensionsStopping', extensionEventListener);
return () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
const ideClient = await IdeClient.getInstance();
ideClient.removeStatusChangeListener(listener);
@@ -290,6 +292,7 @@ export const useSlashCommandProcessor = (
useEffect(() => {
const controller = new AbortController();
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
const commandService = await CommandService.create(
[
@@ -223,8 +223,10 @@ export function useAtCompletion(props: UseAtCompletionProps): void {
};
if (state.status === AtCompletionStatus.INITIALIZING) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
initialize();
} else if (state.status === AtCompletionStatus.SEARCHING) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
search();
}
@@ -98,6 +98,7 @@ export const useExtensionUpdates = (
return !currentState || currentState === ExtensionUpdateState.UNKNOWN;
});
if (extensionsToCheck.length === 0) return;
// eslint-disable-next-line @typescript-eslint/no-floating-promises
checkForAllExtensionUpdates(
extensionsToCheck,
extensionManager,
@@ -200,6 +201,7 @@ export const useExtensionUpdates = (
);
}
if (scheduledUpdate) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Promise.all(updatePromises).then((results) => {
const nonNullResults = results.filter((result) => result != null);
scheduledUpdate.onCompleteCallbacks.forEach((callback) => {
@@ -977,6 +977,7 @@ describe('useGeminiStream', () => {
// Start a query
await act(async () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
result.current.submitQuery('test query');
});
@@ -1036,6 +1037,7 @@ describe('useGeminiStream', () => {
// Start a query
await act(async () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
result.current.submitQuery('test query');
});
@@ -1076,6 +1078,7 @@ describe('useGeminiStream', () => {
// Start a query
await act(async () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
result.current.submitQuery('test query');
});
@@ -1117,6 +1120,7 @@ describe('useGeminiStream', () => {
const { result } = renderTestHook();
await act(async () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
result.current.submitQuery('long running query');
});
@@ -993,6 +993,7 @@ export const useGeminiStream = (
);
if (lastQueryRef.current && lastPromptIdRef.current) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
submitQuery(
lastQueryRef.current,
{ isContinuation: true },
@@ -1176,6 +1177,7 @@ export const useGeminiStream = (
const combinedParts = geminiTools.flatMap(
(toolCall) => toolCall.response.responseParts,
);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
geminiClient.addHistory({
role: 'user',
parts: combinedParts,
@@ -1207,6 +1209,7 @@ export const useGeminiStream = (
return;
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
submitQuery(
responsesToSend,
{
@@ -1342,6 +1345,7 @@ export const useGeminiStream = (
}
}
};
// eslint-disable-next-line @typescript-eslint/no-floating-promises
saveRestorableToolCalls();
}, [
toolCalls,
@@ -37,6 +37,7 @@ export function useGitBranchName(cwd: string): string | undefined {
}, [cwd, setBranchName]);
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
fetchBranchName(); // Initial fetch
const gitLogsHeadPath = path.join(cwd, '.git', 'logs', 'HEAD');
@@ -52,6 +53,7 @@ export function useGitBranchName(cwd: string): string | undefined {
// Changes to .git/logs/HEAD (appends) indicate HEAD has likely changed
if (eventType === 'change' || eventType === 'rename') {
// Handle rename just in case
// eslint-disable-next-line @typescript-eslint/no-floating-promises
fetchBranchName();
}
});
@@ -62,6 +64,7 @@ export function useGitBranchName(cwd: string): string | undefined {
}
};
// eslint-disable-next-line @typescript-eslint/no-floating-promises
setupWatcher();
return () => {
@@ -49,6 +49,7 @@ export function useIdeTrustListener() {
onStoreChange();
};
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
const ideClient = await IdeClient.getInstance();
ideClient.addTrustChangeListener(handleTrustChange);
@@ -56,6 +57,7 @@ export function useIdeTrustListener() {
setConnectionStatus(ideClient.getConnectionStatus().status);
})();
return () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
const ideClient = await IdeClient.getInstance();
ideClient.removeTrustChangeListener(handleTrustChange);
@@ -87,6 +87,7 @@ export function useIncludeDirsTrust(
}
if (added.length > 0 || errors.length > 0) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
finishAddingDirectories(config, addItem, added, errors);
}
config.clearPendingIncludeDirectories();
@@ -151,6 +152,7 @@ export function useIncludeDirsTrust(
/>,
);
} else if (added.length > 0 || errors.length > 0) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
finishAddingDirectories(config, addItem, added, errors);
config.clearPendingIncludeDirectories();
}
@@ -23,6 +23,7 @@ describe('useLoadingIndicator', () => {
afterEach(() => {
vi.useRealTimers(); // Restore real timers after each test
// eslint-disable-next-line @typescript-eslint/no-floating-promises
act(() => vi.runOnlyPendingTimers);
vi.restoreAllMocks();
});
@@ -58,6 +58,7 @@ export const usePrivacySettings = (config: Config) => {
});
}
};
// eslint-disable-next-line @typescript-eslint/no-floating-promises
fetchInitialState();
}, [config]);
@@ -181,6 +181,7 @@ export function usePromptCompletion({
lastSelectedTextRef.current = '';
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
generatePromptSuggestions();
}, [
buffer.text,
@@ -584,11 +584,13 @@ describe('useSelectionList', () => {
});
pressNumber('0');
// eslint-disable-next-line @typescript-eslint/no-floating-promises
act(() => vi.advanceTimersByTime(1000)); // Timeout the '0' input
pressNumber('1');
expect(mockOnSelect).not.toHaveBeenCalled(); // Should be waiting for second digit
// eslint-disable-next-line @typescript-eslint/no-floating-promises
act(() => vi.advanceTimersByTime(1000)); // Timeout '1'
expect(mockOnSelect).toHaveBeenCalledWith('Item 1');
});
@@ -64,6 +64,7 @@ export function useSessionResume({
refreshStaticRef.current(); // Force Static component to re-render with the updated history.
// Give the history to the Gemini client.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
config.getGeminiClient()?.resumeChat(clientHistory, resumedData);
},
[config, isGeminiClientInitialized, setQuittingMessages],
@@ -84,6 +84,7 @@ export function useShellHistory(
const loadedHistory = await readHistoryFile(filePath);
setHistory(loadedHistory.reverse()); // Newest first
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
loadHistory();
}, [projectRoot, storage]);
@@ -97,6 +98,7 @@ export function useShellHistory(
.filter(Boolean);
setHistory(newHistory);
// Write to file in reverse order (oldest first)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
writeHistoryFile(historyFilePath, [...newHistory].reverse());
setHistoryIndex(-1);
},
@@ -232,6 +232,7 @@ function useCommandSuggestions(
}
}
};
// eslint-disable-next-line @typescript-eslint/no-floating-promises
fetchAndSetSuggestions();
return () => abortController.abort();
}