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

+3 -7
View File
@@ -73,16 +73,12 @@ function loadAddon(): unknown {
type BetterSqlite3Type = typeof BetterSqlite3;
type DatabaseInstance = InstanceType<BetterSqlite3Type>;
type DatabaseOptions = ConstructorParameters<BetterSqlite3Type>[1];
type BetterSqlite3Constructor = new (filename?: string | Buffer, options?: DatabaseOptions) => DatabaseInstance;
const Database = function Database(filename?: string | Buffer, options?: DatabaseOptions): DatabaseInstance {
const opts = { ...(options ?? {}), nativeBinding: loadAddon() } as DatabaseOptions;
// The `as any` shrug here is unavoidable — better-sqlite3's
// overload set declares `new Database(...)` returns the class type
// but its default export is a callable that *also* returns it via
// an internal `new.target == null` branch. TS can't reconcile the
// two without `as any`.
return new (BetterSqlite3 as any)(filename, opts);
// better-sqlite3 的默认导出同时支持函数调用和 new 调用;这里只需要构造器形态。
return new (BetterSqlite3 as unknown as BetterSqlite3Constructor)(filename, opts);
} as unknown as BetterSqlite3Type;
export default Database;