mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-20 16:26:44 -07:00
Fixed TypeScript and ESLint errors properly without any or ignores
This commit is contained in:
@@ -116,8 +116,8 @@ expect.extend({
|
||||
|
||||
// Extend Vitest's `expect` interface with the custom matcher's type definition.
|
||||
declare module 'vitest' {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
||||
interface Assertion<T = any> extends CustomMatchers<T> {}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
interface Assertion<T> extends CustomMatchers<T> {}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
interface AsymmetricMatchersContaining extends CustomMatchers {}
|
||||
|
||||
|
||||
@@ -42,8 +42,7 @@ import {
|
||||
type OverflowState,
|
||||
} from '../ui/contexts/OverflowContext.js';
|
||||
|
||||
import { makeFakeConfig } from '../../../../packages/core/src/test-utils/config.js';
|
||||
import { type Config } from '@google/gemini-cli-core';
|
||||
import { makeFakeConfig, type Config } from '@google/gemini-cli-core';
|
||||
import { FakePersistentState } from './persistentStateFake.js';
|
||||
import { AppContext, type AppState } from '../ui/contexts/AppContext.js';
|
||||
import { createMockSettings } from './settings.js';
|
||||
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
type AgentDefinition,
|
||||
CoreToolCallStatus,
|
||||
IdeClient,
|
||||
MCPDiscoveryState,
|
||||
} from '@google/gemini-cli-core';
|
||||
|
||||
// Mock coreEvents
|
||||
@@ -363,22 +364,22 @@ describe('AppContainer State Management Brand New', () => {
|
||||
|
||||
class ErrorBoundary extends Component<
|
||||
{ children: ReactNode },
|
||||
{ hasError: boolean; error: any }
|
||||
{ hasError: boolean; error: unknown }
|
||||
> {
|
||||
constructor(props: any) {
|
||||
constructor(props: { children: ReactNode }) {
|
||||
super(props);
|
||||
this.state = { hasError: false, error: null };
|
||||
}
|
||||
static getDerivedStateFromError(error: any) {
|
||||
static getDerivedStateFromError(error: unknown) {
|
||||
return { hasError: true, error };
|
||||
}
|
||||
override componentDidCatch(error: any, errorInfo: any) {
|
||||
override componentDidCatch(error: unknown, errorInfo: unknown) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('ErrorBoundary caught error:', error, errorInfo);
|
||||
}
|
||||
override render() {
|
||||
if (this.state.hasError) {
|
||||
return <Text>Error: {this.state.error?.message}</Text>;
|
||||
return <Text>Error: {(this.state.error as Error)?.message}</Text>;
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
@@ -451,11 +452,20 @@ describe('AppContainer State Management Brand New', () => {
|
||||
beforeEach(() => {
|
||||
persistentStateMock.reset();
|
||||
vi.clearAllMocks();
|
||||
(global as any).capturedUIState = null;
|
||||
(global as any).capturedInputState = null;
|
||||
(global as any).capturedQuotaState = null;
|
||||
(global as any).capturedUIActions = null;
|
||||
(global as any).capturedOverflowActions = null;
|
||||
(global as typeof global & { capturedUIState: unknown }).capturedUIState =
|
||||
null;
|
||||
(
|
||||
global as typeof global & { capturedInputState: unknown }
|
||||
).capturedInputState = null;
|
||||
(
|
||||
global as typeof global & { capturedQuotaState: unknown }
|
||||
).capturedQuotaState = null;
|
||||
(
|
||||
global as typeof global & { capturedUIActions: unknown }
|
||||
).capturedUIActions = null;
|
||||
(
|
||||
global as typeof global & { capturedOverflowActions: unknown }
|
||||
).capturedOverflowActions = null;
|
||||
|
||||
vi.mocked(useSessionResume).mockReturnValue({
|
||||
loadHistoryForResume: vi.fn().mockResolvedValue(undefined),
|
||||
@@ -474,14 +484,14 @@ describe('AppContainer State Management Brand New', () => {
|
||||
|
||||
vi.spyOn(useMcpStatusModule, 'useMcpStatus').mockReturnValue({
|
||||
isMcpReady: true,
|
||||
discoveryState: 'completed' as any,
|
||||
discoveryState: MCPDiscoveryState.COMPLETED,
|
||||
mcpServerCount: 0,
|
||||
});
|
||||
|
||||
vi.spyOn(IdeClient, 'getInstance').mockResolvedValue({
|
||||
disconnect: vi.fn().mockResolvedValue(undefined),
|
||||
getCurrentIde: vi.fn().mockReturnValue(null),
|
||||
} as any);
|
||||
} as unknown as IdeClient);
|
||||
|
||||
// Initialize mock stdout for terminal title tests
|
||||
|
||||
|
||||
@@ -8,10 +8,13 @@ import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
|
||||
import { act } from 'react';
|
||||
import { renderWithProviders } from '../../test-utils/render.js';
|
||||
import { createMockSettings } from '../../test-utils/settings.js';
|
||||
import { makeFakeConfig } from '../../../../core/src/test-utils/config.js';
|
||||
import { waitFor } from '../../test-utils/async.js';
|
||||
import { AskUserDialog } from './AskUserDialog.js';
|
||||
import { QuestionType, type Question } from '@google/gemini-cli-core';
|
||||
import {
|
||||
QuestionType,
|
||||
type Question,
|
||||
makeFakeConfig,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { UIStateContext, type UIState } from '../contexts/UIStateContext.js';
|
||||
|
||||
// Helper to write to stdin with proper act() wrapping
|
||||
|
||||
@@ -26,7 +26,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { SettingsDialog } from './SettingsDialog.js';
|
||||
import { SettingScope } from '../../config/settings.js';
|
||||
import { createMockSettings } from '../../test-utils/settings.js';
|
||||
import { makeFakeConfig } from "@google/gemini-cli-core/src/test-utils/config.js";
|
||||
import { makeFakeConfig } from '@google/gemini-cli-core';
|
||||
import { act } from 'react';
|
||||
import { TEST_ONLY } from '../../utils/settingsUtils.js';
|
||||
import {
|
||||
|
||||
@@ -9,8 +9,8 @@ import { waitFor } from '../../../test-utils/async.js';
|
||||
import { createMockSettings } from '../../../test-utils/settings.js';
|
||||
import { ToolResultDisplay } from './ToolResultDisplay.js';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { makeFakeConfig } from '../../../../../core/src/test-utils/config.js';
|
||||
import { type AnsiOutput } from '@google/gemini-cli-core';
|
||||
import { makeFakeConfig } from '@google/gemini-cli-core';
|
||||
import type { AnsiOutput, Config } from '@google/gemini-cli-core';
|
||||
|
||||
describe.sequential('ToolResultDisplay', () => {
|
||||
beforeEach(() => {
|
||||
@@ -41,7 +41,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
maxLines={10}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: true }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: true,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: true } }),
|
||||
},
|
||||
);
|
||||
@@ -60,7 +62,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
maxLines={10}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: true }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: true,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: true } }),
|
||||
},
|
||||
);
|
||||
@@ -80,7 +84,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
hasFocus={true}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: true }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: true,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: true } }),
|
||||
},
|
||||
);
|
||||
@@ -94,7 +100,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
|
||||
<ToolResultDisplay resultDisplay="**Some result**" terminalWidth={80} />,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
},
|
||||
);
|
||||
@@ -114,7 +122,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
renderOutputAsMarkdown={false}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
uiState: { constrainHeight: true },
|
||||
},
|
||||
@@ -135,7 +145,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
availableTerminalHeight={20}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
uiState: { constrainHeight: true },
|
||||
},
|
||||
@@ -159,7 +171,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
availableTerminalHeight={20}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
},
|
||||
);
|
||||
@@ -193,7 +207,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
availableTerminalHeight={20}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
},
|
||||
);
|
||||
@@ -215,7 +231,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
availableTerminalHeight={20}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
allowEmptyFrame: true,
|
||||
},
|
||||
@@ -237,7 +255,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
renderOutputAsMarkdown={true}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
uiState: { constrainHeight: true },
|
||||
},
|
||||
@@ -257,7 +277,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
renderOutputAsMarkdown={true}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: true }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: true,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: true } }),
|
||||
},
|
||||
);
|
||||
@@ -344,7 +366,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
maxLines={3}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
uiState: { constrainHeight: true },
|
||||
},
|
||||
@@ -384,7 +408,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
availableTerminalHeight={undefined}
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
uiState: { constrainHeight: true },
|
||||
},
|
||||
@@ -427,7 +453,9 @@ describe.sequential('ToolResultDisplay', () => {
|
||||
overflowDirection="top"
|
||||
/>,
|
||||
{
|
||||
config: makeFakeConfig({ useAlternateBuffer: false }),
|
||||
config: makeFakeConfig({
|
||||
useAlternateBuffer: false,
|
||||
}) as unknown as Config,
|
||||
settings: createMockSettings({ ui: { useAlternateBuffer: false } }),
|
||||
uiState: { constrainHeight: true, terminalHeight: 10 },
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import { useState, useRef, useCallback, useMemo } from 'react';
|
||||
import type { HistoryItem } from '../types.js';
|
||||
import type { ChatRecordingService } from '@google/gemini-cli-core/src/services/chatRecordingService.js';
|
||||
import { type ChatRecordingService } from '@google/gemini-cli-core';
|
||||
|
||||
// Type for the updater function passed to updateHistoryItem
|
||||
type HistoryItemUpdater = (
|
||||
|
||||
Reference in New Issue
Block a user