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

@@ -4,4 +4,4 @@ export {
useKeybindingContext,
useOptionalKeybindingContext,
useRegisterKeybindingContext,
} from '@anthropic/ink'
} from '@anthropic/ink';

View File

@@ -4,22 +4,22 @@
* Wires up app-specific dependencies (notification system, binding loading,
* file watching, debug logging) and re-exports as KeybindingSetup.
*/
import { useCallback } from 'react'
import { useNotifications } from '../context/notifications.js'
import { count } from '../utils/array.js'
import { logForDebugging } from '../utils/debug.js'
import { plural } from '../utils/stringUtils.js'
import { KeybindingSetup as InkKeybindingSetup } from '@anthropic/ink'
import type { KeybindingWarning } from '@anthropic/ink'
import { useCallback } from 'react';
import { useNotifications } from '../context/notifications.js';
import { count } from '../utils/array.js';
import { logForDebugging } from '../utils/debug.js';
import { plural } from '../utils/stringUtils.js';
import { KeybindingSetup as InkKeybindingSetup } from '@anthropic/ink';
import type { KeybindingWarning } from '@anthropic/ink';
import {
initializeKeybindingWatcher,
loadKeybindingsSyncWithWarnings,
subscribeToKeybindingChanges,
} from './loadUserBindings.js'
} from './loadUserBindings.js';
type Props = {
children: React.ReactNode
}
children: React.ReactNode;
};
/**
* Keybinding provider with default + user bindings and hot-reload support.
@@ -42,29 +42,29 @@ type Props = {
* - Chord support with automatic timeout
*/
export function KeybindingSetup({ children }: Props): React.ReactNode {
const { addNotification, removeNotification } = useNotifications()
const { addNotification, removeNotification } = useNotifications();
const handleWarnings = useCallback(
(warnings: KeybindingWarning[], _isReload: boolean) => {
const notificationKey = 'keybinding-config-warning'
const notificationKey = 'keybinding-config-warning';
if (warnings.length === 0) {
removeNotification(notificationKey)
return
removeNotification(notificationKey);
return;
}
const errorCount = count(warnings, w => w.severity === 'error')
const warnCount = count(warnings, w => w.severity === 'warning')
const errorCount = count(warnings, w => w.severity === 'error');
const warnCount = count(warnings, w => w.severity === 'warning');
let message: string
let message: string;
if (errorCount > 0 && warnCount > 0) {
message = `Found ${errorCount} keybinding ${plural(errorCount, 'error')} and ${warnCount} ${plural(warnCount, 'warning')}`
message = `Found ${errorCount} keybinding ${plural(errorCount, 'error')} and ${warnCount} ${plural(warnCount, 'warning')}`;
} else if (errorCount > 0) {
message = `Found ${errorCount} keybinding ${plural(errorCount, 'error')}`
message = `Found ${errorCount} keybinding ${plural(errorCount, 'error')}`;
} else {
message = `Found ${warnCount} keybinding ${plural(warnCount, 'warning')}`
message = `Found ${warnCount} keybinding ${plural(warnCount, 'warning')}`;
}
message += ' · /doctor for details'
message += ' · /doctor for details';
addNotification({
key: notificationKey,
@@ -72,10 +72,10 @@ export function KeybindingSetup({ children }: Props): React.ReactNode {
color: errorCount > 0 ? 'error' : 'warning',
priority: errorCount > 0 ? 'immediate' : 'high',
timeoutMs: 60000,
})
});
},
[addNotification, removeNotification],
)
);
return (
<InkKeybindingSetup
@@ -87,5 +87,5 @@ export function KeybindingSetup({ children }: Props): React.ReactNode {
>
{children}
</InkKeybindingSetup>
)
);
}

View File

@@ -56,12 +56,22 @@ describe('Confirmation context — n/y keys removed (fix: 修复 n 快捷键导
})
test('pressing Enter in Confirmation context resolves to confirm:yes', () => {
const result = resolveKey('', makeKey({ return: true }), ['Confirmation'], bindings)
const result = resolveKey(
'',
makeKey({ return: true }),
['Confirmation'],
bindings,
)
expect(result).toEqual({ type: 'match', action: 'confirm:yes' })
})
test('pressing Escape in Confirmation context resolves to confirm:no', () => {
const result = resolveKey('', makeKey({ escape: true }), ['Confirmation'], bindings)
const result = resolveKey(
'',
makeKey({ escape: true }),
['Confirmation'],
bindings,
)
expect(result).toEqual({ type: 'match', action: 'confirm:no' })
})