style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -1,16 +1,16 @@
import React, { type ReactNode } from 'react'
import type { Theme } from '../../utils/theme.js'
import { Dialog } from '@anthropic/ink'
import { useWizard } from './useWizard.js'
import { WizardNavigationFooter } from './WizardNavigationFooter.js'
import React, { type ReactNode } from 'react';
import type { Theme } from '../../utils/theme.js';
import { Dialog } from '@anthropic/ink';
import { useWizard } from './useWizard.js';
import { WizardNavigationFooter } from './WizardNavigationFooter.js';
type Props = {
title?: string
color?: keyof Theme
children: ReactNode
subtitle?: string
footerText?: ReactNode
}
title?: string;
color?: keyof Theme;
children: ReactNode;
subtitle?: string;
footerText?: ReactNode;
};
export function WizardDialogLayout({
title: titleOverride,
@@ -19,16 +19,9 @@ export function WizardDialogLayout({
subtitle,
footerText,
}: Props): ReactNode {
const {
currentStepIndex,
totalSteps,
title: providerTitle,
showStepCounter,
goBack,
} = useWizard()
const title = titleOverride || providerTitle || 'Wizard'
const stepSuffix =
showStepCounter !== false ? ` (${currentStepIndex + 1}/${totalSteps})` : ''
const { currentStepIndex, totalSteps, title: providerTitle, showStepCounter, goBack } = useWizard();
const title = titleOverride || providerTitle || 'Wizard';
const stepSuffix = showStepCounter !== false ? ` (${currentStepIndex + 1}/${totalSteps})` : '';
return (
<>
@@ -44,5 +37,5 @@ export function WizardDialogLayout({
</Dialog>
<WizardNavigationFooter instructions={footerText} />
</>
)
);
}

View File

@@ -1,36 +1,27 @@
import React, { type ReactNode } from 'react'
import { useExitOnCtrlCDWithKeybindings } from '../../hooks/useExitOnCtrlCDWithKeybindings.js'
import { Box, Text } from '@anthropic/ink'
import { ConfigurableShortcutHint } from '../ConfigurableShortcutHint.js'
import { Byline, KeyboardShortcutHint } from '@anthropic/ink'
import React, { type ReactNode } from 'react';
import { useExitOnCtrlCDWithKeybindings } from '../../hooks/useExitOnCtrlCDWithKeybindings.js';
import { Box, Text } from '@anthropic/ink';
import { ConfigurableShortcutHint } from '../ConfigurableShortcutHint.js';
import { Byline, KeyboardShortcutHint } from '@anthropic/ink';
type Props = {
instructions?: ReactNode
}
instructions?: ReactNode;
};
export function WizardNavigationFooter({
instructions = (
<Byline>
<KeyboardShortcutHint shortcut="↑↓" action="navigate" />
<KeyboardShortcutHint shortcut="Enter" action="select" />
<ConfigurableShortcutHint
action="confirm:no"
context="Confirmation"
fallback="Esc"
description="go back"
/>
<ConfigurableShortcutHint action="confirm:no" context="Confirmation" fallback="Esc" description="go back" />
</Byline>
),
}: Props): ReactNode {
const exitState = useExitOnCtrlCDWithKeybindings()
const exitState = useExitOnCtrlCDWithKeybindings();
return (
<Box marginLeft={3} marginTop={1}>
<Text dimColor>
{exitState.pending
? `Press ${exitState.keyName} again to exit`
: instructions}
</Text>
<Text dimColor>{exitState.pending ? `Press ${exitState.keyName} again to exit` : instructions}</Text>
</Box>
)
);
}

View File

@@ -1,17 +1,10 @@
import React, {
createContext,
type ReactNode,
useCallback,
useEffect,
useMemo,
useState,
} from 'react'
import { useExitOnCtrlCDWithKeybindings } from '../../hooks/useExitOnCtrlCDWithKeybindings.js'
import type { WizardContextValue, WizardProviderProps } from './types.js'
import React, { createContext, type ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
import { useExitOnCtrlCDWithKeybindings } from '../../hooks/useExitOnCtrlCDWithKeybindings.js';
import type { WizardContextValue, WizardProviderProps } from './types.js';
// Use any here for the context since it will be cast properly when used
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const WizardContext = createContext<WizardContextValue<any> | null>(null)
export const WizardContext = createContext<WizardContextValue<any> | null>(null);
export function WizardProvider<T extends Record<string, unknown>>({
steps,
@@ -21,73 +14,80 @@ export function WizardProvider<T extends Record<string, unknown>>({
children,
title,
showStepCounter = true,
}: WizardProviderProps & { initialData?: T; onComplete: (data: T) => void; onCancel: () => void; children: ReactNode; title: string; showStepCounter?: boolean }): ReactNode {
const [currentStepIndex, setCurrentStepIndex] = useState(0)
const [wizardData, setWizardData] = useState<T>(initialData)
const [isCompleted, setIsCompleted] = useState(false)
const [navigationHistory, setNavigationHistory] = useState<number[]>([])
}: WizardProviderProps & {
initialData?: T;
onComplete: (data: T) => void;
onCancel: () => void;
children: ReactNode;
title: string;
showStepCounter?: boolean;
}): ReactNode {
const [currentStepIndex, setCurrentStepIndex] = useState(0);
const [wizardData, setWizardData] = useState<T>(initialData);
const [isCompleted, setIsCompleted] = useState(false);
const [navigationHistory, setNavigationHistory] = useState<number[]>([]);
useExitOnCtrlCDWithKeybindings()
useExitOnCtrlCDWithKeybindings();
// Handle completion in useEffect to avoid updating parent during render
useEffect(() => {
if (isCompleted) {
setNavigationHistory([])
void onComplete(wizardData)
setNavigationHistory([]);
void onComplete(wizardData);
}
}, [isCompleted, wizardData, onComplete])
}, [isCompleted, wizardData, onComplete]);
const goNext = useCallback(() => {
if (currentStepIndex < steps.length - 1) {
// If we have history (non-linear flow), add current step to it
if (navigationHistory.length > 0) {
setNavigationHistory(prev => [...prev, currentStepIndex])
setNavigationHistory(prev => [...prev, currentStepIndex]);
}
setCurrentStepIndex(prev => prev + 1)
setCurrentStepIndex(prev => prev + 1);
} else {
// Mark as completed, which will trigger useEffect
setIsCompleted(true)
setIsCompleted(true);
}
}, [currentStepIndex, steps.length, navigationHistory])
}, [currentStepIndex, steps.length, navigationHistory]);
const goBack = useCallback(() => {
// Check if we have navigation history to use
if (navigationHistory.length > 0) {
const previousStep = navigationHistory[navigationHistory.length - 1]
const previousStep = navigationHistory[navigationHistory.length - 1];
if (previousStep !== undefined) {
setNavigationHistory(prev => prev.slice(0, -1))
setCurrentStepIndex(previousStep)
setNavigationHistory(prev => prev.slice(0, -1));
setCurrentStepIndex(previousStep);
}
} else if (currentStepIndex > 0) {
// Fallback to simple decrement if no history
setCurrentStepIndex(prev => prev - 1)
setCurrentStepIndex(prev => prev - 1);
} else if (onCancel) {
onCancel()
onCancel();
}
}, [currentStepIndex, navigationHistory, onCancel])
}, [currentStepIndex, navigationHistory, onCancel]);
const goToStep = useCallback(
(index: number) => {
if (index >= 0 && index < steps.length) {
// Push current step to history before jumping
setNavigationHistory(prev => [...prev, currentStepIndex])
setCurrentStepIndex(index)
setNavigationHistory(prev => [...prev, currentStepIndex]);
setCurrentStepIndex(index);
}
},
[currentStepIndex, steps.length],
)
);
const cancel = useCallback(() => {
setNavigationHistory([])
setNavigationHistory([]);
if (onCancel) {
onCancel()
onCancel();
}
}, [onCancel])
}, [onCancel]);
const updateWizardData = useCallback((updates: Partial<T>) => {
setWizardData(prev => ({ ...prev, ...updates }))
}, [])
setWizardData(prev => ({ ...prev, ...updates }));
}, []);
const contextValue = useMemo<WizardContextValue<T>>(
() => ({
@@ -115,17 +115,13 @@ export function WizardProvider<T extends Record<string, unknown>>({
title,
showStepCounter,
],
)
);
const CurrentStepComponent = steps[currentStepIndex]
const CurrentStepComponent = steps[currentStepIndex];
if (!CurrentStepComponent || isCompleted) {
return null
return null;
}
return (
<WizardContext.Provider value={contextValue}>
{children || <CurrentStepComponent />}
</WizardContext.Provider>
)
return <WizardContext.Provider value={contextValue}>{children || <CurrentStepComponent />}</WizardContext.Provider>;
}

View File

@@ -1,4 +1,4 @@
// Auto-generated stub — replace with real implementation
export type WizardContextValue<T = any> = any;
export type WizardProviderProps = any;
export type WizardStepComponent = any;
export type WizardContextValue<T = any> = any
export type WizardProviderProps = any
export type WizardStepComponent = any