mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,25 +1,22 @@
|
||||
import React from 'react'
|
||||
import { Box, Dialog, wrappedRender as render, Text } from '@anthropic/ink'
|
||||
import { KeybindingSetup } from '../keybindings/KeybindingProviderSetup.js'
|
||||
import { AppStateProvider } from '../state/AppState.js'
|
||||
import type { ConfigParseError } from '../utils/errors.js'
|
||||
import { getBaseRenderOptions } from '../utils/renderOptions.js'
|
||||
import {
|
||||
jsonStringify,
|
||||
writeFileSync_DEPRECATED,
|
||||
} from '../utils/slowOperations.js'
|
||||
import type { ThemeName } from '../utils/theme.js'
|
||||
import { Select } from './CustomSelect/index.js'
|
||||
import React from 'react';
|
||||
import { Box, Dialog, wrappedRender as render, Text } from '@anthropic/ink';
|
||||
import { KeybindingSetup } from '../keybindings/KeybindingProviderSetup.js';
|
||||
import { AppStateProvider } from '../state/AppState.js';
|
||||
import type { ConfigParseError } from '../utils/errors.js';
|
||||
import { getBaseRenderOptions } from '../utils/renderOptions.js';
|
||||
import { jsonStringify, writeFileSync_DEPRECATED } from '../utils/slowOperations.js';
|
||||
import type { ThemeName } from '../utils/theme.js';
|
||||
import { Select } from './CustomSelect/index.js';
|
||||
|
||||
interface InvalidConfigHandlerProps {
|
||||
error: ConfigParseError
|
||||
error: ConfigParseError;
|
||||
}
|
||||
|
||||
interface InvalidConfigDialogProps {
|
||||
filePath: string
|
||||
errorDescription: string
|
||||
onExit: () => void
|
||||
onReset: () => void
|
||||
filePath: string;
|
||||
errorDescription: string;
|
||||
onExit: () => void;
|
||||
onReset: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,18 +31,17 @@ function InvalidConfigDialog({
|
||||
// Handler for Select onChange
|
||||
const handleSelect = (value: string) => {
|
||||
if (value === 'exit') {
|
||||
onExit()
|
||||
onExit();
|
||||
} else {
|
||||
onReset()
|
||||
onReset();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog title="Configuration Error" color="error" onCancel={onExit}>
|
||||
<Box flexDirection="column" gap={1}>
|
||||
<Text>
|
||||
The configuration file at <Text bold>{filePath}</Text> contains
|
||||
invalid JSON.
|
||||
The configuration file at <Text bold>{filePath}</Text> contains invalid JSON.
|
||||
</Text>
|
||||
<Text>{errorDescription}</Text>
|
||||
</Box>
|
||||
@@ -61,27 +57,25 @@ function InvalidConfigDialog({
|
||||
/>
|
||||
</Box>
|
||||
</Dialog>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe fallback theme name for error dialogs to avoid circular dependency.
|
||||
* Uses a hardcoded dark theme that doesn't require reading from config.
|
||||
*/
|
||||
const SAFE_ERROR_THEME_NAME: ThemeName = 'dark'
|
||||
const SAFE_ERROR_THEME_NAME: ThemeName = 'dark';
|
||||
|
||||
export async function showInvalidConfigDialog({
|
||||
error,
|
||||
}: InvalidConfigHandlerProps): Promise<void> {
|
||||
export async function showInvalidConfigDialog({ error }: InvalidConfigHandlerProps): Promise<void> {
|
||||
// Extend RenderOptions with theme property for this specific usage
|
||||
type SafeRenderOptions = Parameters<typeof render>[1] & { theme?: ThemeName }
|
||||
type SafeRenderOptions = Parameters<typeof render>[1] & { theme?: ThemeName };
|
||||
|
||||
const renderOptions: SafeRenderOptions = {
|
||||
...getBaseRenderOptions(false),
|
||||
// IMPORTANT: Use hardcoded theme name to avoid circular dependency with getGlobalConfig()
|
||||
// This allows the error dialog to show even when config file has JSON syntax errors
|
||||
theme: SAFE_ERROR_THEME_NAME,
|
||||
}
|
||||
};
|
||||
|
||||
// biome-ignore lint/suspicious/noAsyncPromiseExecutor: render must be awaited inside executor
|
||||
await new Promise<void>(async resolve => {
|
||||
@@ -92,24 +86,23 @@ export async function showInvalidConfigDialog({
|
||||
filePath={error.filePath}
|
||||
errorDescription={error.message}
|
||||
onExit={() => {
|
||||
unmount()
|
||||
void resolve()
|
||||
process.exit(1)
|
||||
unmount();
|
||||
void resolve();
|
||||
process.exit(1);
|
||||
}}
|
||||
onReset={() => {
|
||||
writeFileSync_DEPRECATED(
|
||||
error.filePath,
|
||||
jsonStringify(error.defaultConfig, null, 2),
|
||||
{ flush: false, encoding: 'utf8' },
|
||||
)
|
||||
unmount()
|
||||
void resolve()
|
||||
process.exit(0)
|
||||
writeFileSync_DEPRECATED(error.filePath, jsonStringify(error.defaultConfig, null, 2), {
|
||||
flush: false,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
unmount();
|
||||
void resolve();
|
||||
process.exit(0);
|
||||
}}
|
||||
/>
|
||||
</KeybindingSetup>
|
||||
</AppStateProvider>,
|
||||
renderOptions,
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user