Enforce no-explicit-any; allow in tests

Enable @typescript-eslint/no-explicit-any as an error in the ESLint config to tighten typing across the codebase, and add an override to disable this rule for test files. Also apply non-functional cleanup in packages/proton/src/runtime.ts: reorder/imports and adjust formatting/indentation and string alignment for readability — no behavioral changes.
This commit is contained in:
手瓜一十雪 committed 2026-05-24 13:38:13 +08:00
1 parent acc5084647
commit 80ee12ecc2
36 files changed
+229 -147

No files matched your search

+5 -4
View File
@@ -3,6 +3,7 @@ import { createHash } from 'crypto';
import { statSync, createReadStream, writeFileSync, unlinkSync } from 'fs';
import { basename, join } from 'path';
import { tmpdir } from 'os';
import type { JsonValue } from '@snowluma/common/json';
// 群相册信息
export interface GroupAlbumInfo {
@@ -10,13 +11,13 @@ export interface GroupAlbumInfo {
name: string;
picNum: number;
createTime: number;
[key: string]: any;
[key: string]: JsonValue;
}
// 获取群相册列表返回
export interface GroupAlbumListRet {
album: GroupAlbumInfo[];
[key: string]: any;
[key: string]: JsonValue | GroupAlbumInfo[];
}
// 相册媒体信息
@@ -24,7 +25,7 @@ export interface AlbumMediaInfo {
photoId: string;
url: string;
uploadTime: number;
[key: string]: any;
[key: string]: JsonValue;
}
/**
@@ -150,7 +151,7 @@ async function uploadAlbumSlice(
session: string,
filePath: string,
// 移除 offset 和 chunkSize 参数,改为在内部控制
imgMd5: string,
_imgMd5: string,
skey: string,
pskey: string,
uin: string
+4 -3
View File
@@ -1,5 +1,6 @@
import { RequestUtil, cookieToString, getBknFromCookie } from './request-util';
import { createLogger } from '@snowluma/common/logger';
import type { JsonObject } from '@snowluma/common/json';
const log = createLogger('Bridge.Web');
@@ -8,10 +9,10 @@ export interface GroupEssenceMsgRet {
retcode: number;
data: {
is_end: boolean;
msg_list: any[]; // 具体结构视需要补充
[key: string]: any;
msg_list: JsonObject[]; // 具体结构视需要补充
[key: string]: JsonObject[] | boolean | string | number | null;
};
[key: string]: any;
[key: string]: JsonObject | JsonObject[] | boolean | string | number | null;
}
+29 -9
View File
@@ -3,6 +3,26 @@ import { createLogger } from '@snowluma/common/logger';
const log = createLogger('Bridge.Web');
export interface WebHonorItem {
[key: string]: import('@snowluma/common/json').JsonValue;
user_id: number | string | null;
nickname: string;
avatar: string;
description: string;
}
interface RawHonorItem {
uin?: number | string;
name?: string;
avatar?: string;
desc?: string;
}
interface HonorInitialState {
talkativeList?: RawHonorItem[];
actorList?: RawHonorItem[];
}
export enum WebHonorType {
TALKATIVE = 'talkative',
PERFORMER = 'performer',
@@ -12,8 +32,8 @@ export enum WebHonorType {
}
async function fetchHonorData(cookieObject: Record<string, string>, groupCode: string, type: number) {
let resJson;
async function fetchHonorData(cookieObject: Record<string, string>, groupCode: string, type: number): Promise<RawHonorItem[] | undefined> {
let resJson: HonorInitialState | undefined;
try {
const res = await RequestUtil.HttpGetText(
`https://qun.qq.com/interactive/honorlist?${new URLSearchParams({
@@ -26,7 +46,7 @@ async function fetchHonorData(cookieObject: Record<string, string>, groupCode: s
);
const match = /window\.__INITIAL_STATE__=(.*?);/.exec(res);
if (match?.[1]) {
resJson = JSON.parse(match[1].trim());
resJson = JSON.parse(match[1].trim()) as HonorInitialState;
}
return type === 1 ? resJson?.talkativeList : resJson?.actorList;
} catch (e) {
@@ -34,16 +54,16 @@ async function fetchHonorData(cookieObject: Record<string, string>, groupCode: s
}
}
export async function getHonorListWebAPI(cookieObject: Record<string, string>, groupCode: string, type: number) {
export async function getHonorListWebAPI(cookieObject: Record<string, string>, groupCode: string, type: number): Promise<WebHonorItem[]> {
try {
const data = await fetchHonorData(cookieObject, groupCode, type);
if (!data) return [];
return data.map((item: any) => ({
user_id: item?.uin,
nickname: item?.name,
avatar: item?.avatar,
description: item?.desc,
return data.map((item) => ({
user_id: item?.uin ?? null,
nickname: item?.name ?? '',
avatar: item?.avatar ?? '',
description: item?.desc ?? '',
}));
} catch (e) {
log.warn('getHonorListWebAPI failed (group=%s type=%d): %s',
+6 -5
View File
@@ -1,19 +1,20 @@
import { RequestUtil, cookieToString } from './request-util';
import https from 'node:https';
import { createLogger } from '@snowluma/common/logger';
import type { JsonValue } from '@snowluma/common/json';
const log = createLogger('Bridge.Web');
export interface SetNoticeRetSuccess {
ec?: number;
em?: string;
[key: string]: any;
[key: string]: JsonValue | undefined;
}
export interface UploadImageRetSuccess {
ec?: number;
id?: string;
[key: string]: any;
[key: string]: JsonValue | undefined;
}
export interface WebApiGroupNoticeFeed {
@@ -24,16 +25,16 @@ export interface WebApiGroupNoticeFeed {
text: string;
pics?: Array<{ id: string; w: number; h: number }>;
};
settings: any;
settings: JsonValue;
read_num: number;
[key: string]: any;
[key: string]: JsonValue;
}
export interface WebApiGroupNoticeRet {
ec: number;
em?: string;
feeds?: Record<string, WebApiGroupNoticeFeed>;
[key: string]: any;
[key: string]: JsonValue | Record<string, WebApiGroupNoticeFeed> | undefined;
}
export function calculateBkn(key: string): string {
+6 -4
View File
@@ -1,6 +1,8 @@
import https from 'node:https';
import http from 'node:http';
type RequestBody = string | Buffer | Uint8Array | Record<string, unknown> | undefined;
export class RequestUtil {
static async HttpsGetCookies(url: string): Promise<{ [key: string]: string; }> {
const client = url.startsWith('https') ? https : http;
@@ -50,7 +52,7 @@ export class RequestUtil {
});
}
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: any, headers: {
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: RequestBody, headers: {
[key: string]: string;
} = {}, isJsonRet: boolean = true, isArgJson: boolean = true, maxRedirects: number = 5): Promise<T> {
const option = new URL(url);
@@ -91,8 +93,8 @@ export class RequestUtil {
} else {
reject(new Error(`Unexpected status code: ${res.statusCode}`));
}
} catch (parseError: any) {
reject(new Error(parseError.message));
} catch (parseError: unknown) {
reject(new Error(parseError instanceof Error ? parseError.message : String(parseError)));
}
});
});
@@ -105,7 +107,7 @@ export class RequestUtil {
});
}
static async HttpGetText(url: string, method: string = 'GET', data?: any, headers: { [key: string]: string; } = {}) {
static async HttpGetText(url: string, method: string = 'GET', data?: RequestBody, headers: { [key: string]: string; } = {}) {
return this.HttpGetJson<string>(url, method, data, headers, false, false);
}
}