From ed9199200910b240d5ba1b3a691af40b6fe3f095 Mon Sep 17 00:00:00 2001 From: William So Date: Wed, 10 Apr 2024 02:07:15 +0800 Subject: [PATCH] Fix compile errors Signed-off-by: William So --- assets/locales.ts | 3 +-- sources/modals.ts | 1 + sources/obsidian.ts | 2 ++ sources/settings-tab.ts | 10 +++++++--- sources/settings.ts | 6 +++--- sources/util.ts | 5 ++--- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/assets/locales.ts b/assets/locales.ts index 394d1c3..3e162fc 100644 --- a/assets/locales.ts +++ b/assets/locales.ts @@ -65,10 +65,9 @@ export function mergeResources( }>> = {} for (const res of resources) { for (const [lang, locale] of Object.entries(res)) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-multi-assign + // eslint-disable-next-line no-multi-assign const ret0 = ret[lang] ??= {} for (const [ns, resource] of Object.entries(locale)) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition (ret0[ns] ??= ((data: (() => AsyncOrSync)[] = []): { (): AsyncOrSync diff --git a/sources/modals.ts b/sources/modals.ts index b7bfe3b..94f92d0 100644 --- a/sources/modals.ts +++ b/sources/modals.ts @@ -522,6 +522,7 @@ export class EditDataModal extends Modal { protected replaceData(data: typeof this.data): void { clearProperties(this.data) + // eslint-disable-next-line @typescript-eslint/no-floating-promises Object.assign(this.data, data) } diff --git a/sources/obsidian.ts b/sources/obsidian.ts index ef9f703..a3b9dd4 100644 --- a/sources/obsidian.ts +++ b/sources/obsidian.ts @@ -102,6 +102,7 @@ export abstract class ResourceComponent extends Component { try { loading = this.load0() } catch (error) { + // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors loading = Promise.reject(error) } (async (): Promise => { @@ -359,6 +360,7 @@ export async function awaitCSS( classList.remove(awaitCSS.CLASS) resolve() } catch (error) { + // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error) } finally { obsr.disconnect() } }) diff --git a/sources/settings-tab.ts b/sources/settings-tab.ts index 8c2a97e..9dd7192 100644 --- a/sources/settings-tab.ts +++ b/sources/settings-tab.ts @@ -38,7 +38,9 @@ export abstract class AdvancedSettingTab { this.onUnload() }, )) }) - .catch(error => { activeSelf(this.containerEl).console.error(error) }) + .catch((error: unknown) => { + activeSelf(this.containerEl).console.error(error) + }) } public display(): void { @@ -105,6 +107,7 @@ export abstract class AdvancedSettingTab settings.mutate(settingsM => { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition settingsM.language = value || defaults.language }), ), @@ -228,7 +231,7 @@ export abstract class AdvancedSettingTab { undoable = true component.setCta() - }).catch(error => { + }).catch((error: unknown) => { activeSelf(component.buttonEl).console.error(error) }) }, @@ -318,6 +321,7 @@ export abstract class AdvancedSettingTab { + (local ? localSettings : settings).write().catch((error: unknown) => { activeSelf(containerEl).console.error(error) }) ui.update() diff --git a/sources/settings.ts b/sources/settings.ts index 6871909..fa37c5b 100644 --- a/sources/settings.ts +++ b/sources/settings.ts @@ -311,7 +311,7 @@ export function registerSettingsCommands(context: PluginContext): void { } clearProperties(fm) Object.assign(fm, context.settings) - }).catch(error => { + }).catch((error: unknown) => { printError(anyToError(error), () => i18n.t( "errors.error-processing-frontmatter", { @@ -355,7 +355,7 @@ export function registerSettingsCommands(context: PluginContext): void { ) return ret ?? {} }) - settings.write().catch(error => { + settings.write().catch((error: unknown) => { activeSelf(lastEvent).console.error(error) }) } catch (error) { @@ -380,7 +380,7 @@ export function registerSettingsCommands(context: PluginContext): void { cleanFrontmatterCache( metadataCache.getFileCache(file)?.frontmatter, )) - settings.write().catch(error => { + settings.write().catch((error: unknown) => { activeSelf(lastEvent).console.error(error) }) } catch (error) { diff --git a/sources/util.ts b/sources/util.ts index 3869991..246a21d 100644 --- a/sources/util.ts +++ b/sources/util.ts @@ -49,7 +49,7 @@ export class EventEmitterLite { readonly #listeners: ((...args: A) => unknown)[] = [] public async emit(...args: A): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject: (reason?: unknown) => unknown) => { this.lock.acquire(EventEmitterLite.emitLock, async () => { // Copy to prevent concurrent modification const emitted = [...this.#listeners] @@ -356,6 +356,7 @@ function deepFreeze0(value: T, freezing: WeakSet): DeepReadonly { for (const subkey of typedOwnKeys(value)) { const subvalue = value[subkey] if (isObject(subvalue) && !freezing.has(subvalue)) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises deepFreeze0(subvalue, freezing) } } @@ -547,7 +548,6 @@ export function lazyProxy( get(target, property, receiver): unknown { const own = Reflect.getOwnPropertyDescriptor(target, property) if (!(own?.configurable ?? true) && - // eslint-disable-next-line @typescript-eslint/no-extra-parens (!(own?.writable ?? true) || (own?.set && !own.get))) { return Reflect.get(target, property, receiver) } @@ -623,7 +623,6 @@ export function lazyProxy( set(target, property, newValue, receiver): boolean { const own = Reflect.getOwnPropertyDescriptor(target, property) if (!(own?.configurable ?? true) && - // eslint-disable-next-line @typescript-eslint/no-extra-parens (!(own?.writable ?? true) || (own?.get && !own.set)) && !Reflect.set(target, property, newValue, receiver)) { return false