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