chore(lint): reduce warning debt across core adapters and model clients

This commit is contained in:
William Valentin
2026-02-15 23:03:42 -08:00
parent 92da407e22
commit 49b752e8b0
17 changed files with 239 additions and 117 deletions
+20 -15
View File
@@ -20,6 +20,11 @@ export interface DoctorContext {
}
type Check = (ctx: DoctorContext) => Promise<CheckResult>;
type UnknownRecord = Record<string, unknown>;
const asRecord = (value: unknown): UnknownRecord | undefined => (
value && typeof value === 'object' ? value as UnknownRecord : undefined
);
const checkConfigExists: Check = async (ctx) => {
if (existsSync(ctx.configPath)) {
@@ -78,8 +83,9 @@ const checkDeprecatedConfigKeys: Check = async (ctx) => {
try {
const raw = readFileSync(ctx.configPath, 'utf-8');
const parsed = parse(raw) as any;
const tailscaleOnly = Boolean(parsed?.server && typeof parsed.server === 'object' && 'tailscale_only' in parsed.server);
const parsed = asRecord(parse(raw));
const server = asRecord(parsed?.server);
const tailscaleOnly = Boolean(server && 'tailscale_only' in server);
if (tailscaleOnly) {
return {
@@ -198,11 +204,11 @@ const checkModelConnectivity: Check = async (ctx) => {
return true;
}
const oauth = o.oauth;
const oauthRecord = asRecord(oauth);
return Boolean(
oauth
&& typeof oauth === 'object'
&& typeof (oauth as any).access_token === 'string'
&& typeof (oauth as any).refresh_token === 'string',
oauthRecord
&& typeof oauthRecord.access_token === 'string'
&& typeof oauthRecord.refresh_token === 'string',
);
};
@@ -213,22 +219,21 @@ const checkModelConnectivity: Check = async (ctx) => {
}
const o = openai as Record<string, unknown>;
const apiKey = o.api_key;
const apiKeyRecord = asRecord(apiKey);
return Boolean(
apiKey
&& typeof apiKey === 'object'
&& typeof (apiKey as any).api_key === 'string'
&& (apiKey as any).api_key.length > 0,
typeof apiKeyRecord?.api_key === 'string'
&& apiKeyRecord.api_key.length > 0,
);
};
const storeAnthropicApiKeyPresent = (): boolean => {
const anthropic = store.anthropic as any;
return Boolean(anthropic && typeof anthropic.api_key === 'string' && anthropic.api_key.length > 0);
const anthropic = asRecord(store.anthropic);
return Boolean(typeof anthropic?.api_key === 'string' && anthropic.api_key.length > 0);
};
const storeAnthropicAuthTokenPresent = (): boolean => {
const anthropic = store.anthropic as any;
return Boolean(anthropic && typeof anthropic.auth_token === 'string' && anthropic.auth_token.length > 0);
const anthropic = asRecord(store.anthropic);
return Boolean(typeof anthropic?.auth_token === 'string' && anthropic.auth_token.length > 0);
};
const formatSources = (sources: { config: boolean; env: boolean; store: boolean }): string => {
@@ -318,7 +323,7 @@ const checkModelConnectivity: Check = async (ctx) => {
const envVar = envVarMap[provider];
const sources = {
config: typeof cfg.api_key === 'string' && (cfg.api_key as string).length > 0,
env: Boolean(envVar && process.env[envVar] && process.env[envVar]!.length > 0),
env: Boolean(envVar && typeof process.env[envVar] === 'string' && process.env[envVar].length > 0),
store: false,
};
const ok = sources.config || sources.env;