Browse Source

chore: resolve all TypeScript lint warnings in PlatformServiceMixin

- Fix remaining type warnings by specifying Settings for cache and using this._setCached directly
- Add eslint-disable-next-line comments for unavoidable (this as any) usages required for Vue context access
- All @typescript-eslint/no-explicit-any warnings are now suppressed or resolved
- Lint passes with zero warnings or errors
- No functional changes; improves code clarity and developer experience
pull/142/head
Matthew Raymer 3 days ago
parent
commit
c63799999a
  1. 28
      src/utils/PlatformServiceMixin.ts

28
src/utils/PlatformServiceMixin.ts

@ -221,9 +221,11 @@ export const PlatformServiceMixin = {
*/ */
async $dbQuery(sql: string, params?: unknown[]) { async $dbQuery(sql: string, params?: unknown[]) {
try { try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return await (this as any).platformService.dbQuery(sql, params); return await (this as any).platformService.dbQuery(sql, params);
} catch (error) { } catch (error) {
logger.error( logger.error(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
`[${(this as any).$options.name}] Database query failed:`, `[${(this as any).$options.name}] Database query failed:`,
{ {
sql, sql,
@ -240,13 +242,18 @@ export const PlatformServiceMixin = {
*/ */
async $dbExec(sql: string, params?: unknown[]) { async $dbExec(sql: string, params?: unknown[]) {
try { try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return await (this as any).platformService.dbExec(sql, params); return await (this as any).platformService.dbExec(sql, params);
} catch (error) { } catch (error) {
logger.error(`[${(this as any).$options.name}] Database exec failed:`, { logger.error(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
`[${(this as any).$options.name}] Database exec failed:`,
{
sql, sql,
params, params,
error, error,
}); },
);
throw error; throw error;
} }
}, },
@ -256,9 +263,11 @@ export const PlatformServiceMixin = {
*/ */
async $dbGetOneRow(sql: string, params?: unknown[]) { async $dbGetOneRow(sql: string, params?: unknown[]) {
try { try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return await (this as any).platformService.dbGetOneRow(sql, params); return await (this as any).platformService.dbGetOneRow(sql, params);
} catch (error) { } catch (error) {
logger.error( logger.error(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
`[${(this as any).$options.name}] Database single row query failed:`, `[${(this as any).$options.name}] Database single row query failed:`,
{ {
sql, sql,
@ -417,6 +426,7 @@ export const PlatformServiceMixin = {
sql: string, sql: string,
params: unknown[] = [], params: unknown[] = [],
): Promise<QueryExecResult | undefined> { ): Promise<QueryExecResult | undefined> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return await (this as any).platformService.dbQuery(sql, params); return await (this as any).platformService.dbQuery(sql, params);
}, },
@ -429,6 +439,7 @@ export const PlatformServiceMixin = {
sql: string, sql: string,
params: unknown[] = [], params: unknown[] = [],
): Promise<DatabaseExecResult> { ): Promise<DatabaseExecResult> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return await (this as any).platformService.dbExec(sql, params); return await (this as any).platformService.dbExec(sql, params);
}, },
@ -441,6 +452,7 @@ export const PlatformServiceMixin = {
sql: string, sql: string,
params: unknown[] = [], params: unknown[] = [],
): Promise<unknown[] | undefined> { ): Promise<unknown[] | undefined> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return await (this as any).platformService.dbGetOneRow(sql, params); return await (this as any).platformService.dbGetOneRow(sql, params);
}, },
@ -459,6 +471,7 @@ export const PlatformServiceMixin = {
sql: string, sql: string,
params: unknown[] = [], params: unknown[] = [],
): Promise<T[]> { ): Promise<T[]> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result = await (this as any).platformService.dbQuery(sql, params); const result = await (this as any).platformService.dbQuery(sql, params);
if (!result?.columns || !result?.values) { if (!result?.columns || !result?.values) {
return []; return [];
@ -515,7 +528,7 @@ export const PlatformServiceMixin = {
*/ */
async $settings(defaults: Settings = {}): Promise<Settings> { async $settings(defaults: Settings = {}): Promise<Settings> {
const cacheKey = `settings_${String(MASTER_SETTINGS_KEY)}`; const cacheKey = `settings_${String(MASTER_SETTINGS_KEY)}`;
const cached = this._getCached<any>(cacheKey); const cached = this._getCached<Settings>(cacheKey);
if (cached) { if (cached) {
return { ...cached, ...defaults }; // Merge with any new defaults return { ...cached, ...defaults }; // Merge with any new defaults
} }
@ -536,11 +549,7 @@ export const PlatformServiceMixin = {
settings.apiServer = DEFAULT_ENDORSER_API_SERVER; settings.apiServer = DEFAULT_ENDORSER_API_SERVER;
} }
return (this as any)._setCached( return this._setCached(cacheKey, settings, CACHE_DEFAULTS.settings);
cacheKey,
settings,
CACHE_DEFAULTS.settings,
);
}, },
/** /**
@ -553,6 +562,7 @@ export const PlatformServiceMixin = {
did?: string, did?: string,
defaults: Settings = {}, defaults: Settings = {},
): Promise<Settings> { ): Promise<Settings> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const currentDid = did || (this as any).activeDid; const currentDid = did || (this as any).activeDid;
const cacheKey = `account_settings_${currentDid || "default"}`; const cacheKey = `account_settings_${currentDid || "default"}`;
@ -622,6 +632,7 @@ export const PlatformServiceMixin = {
* @returns Promise<boolean> Success status * @returns Promise<boolean> Success status
*/ */
async $saveMySettings(changes: Partial<Settings>): Promise<boolean> { async $saveMySettings(changes: Partial<Settings>): Promise<boolean> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const currentDid = (this as any).activeDid; const currentDid = (this as any).activeDid;
if (!currentDid) { if (!currentDid) {
return await this.$saveSettings(changes); return await this.$saveSettings(changes);
@ -639,6 +650,7 @@ export const PlatformServiceMixin = {
*/ */
async $refreshSettings(): Promise<Settings> { async $refreshSettings(): Promise<Settings> {
this._invalidateCache(`settings_${MASTER_SETTINGS_KEY}`); this._invalidateCache(`settings_${MASTER_SETTINGS_KEY}`);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const currentDid = (this as any).activeDid; const currentDid = (this as any).activeDid;
if (currentDid) { if (currentDid) {
this._invalidateCache(`account_settings_${currentDid}`); this._invalidateCache(`account_settings_${currentDid}`);

Loading…
Cancel
Save