Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
Signed-off-by: William So <[email protected]>
  • Loading branch information
polyipseity committed Apr 9, 2024
1 parent 2a3693a commit ed91992
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
3 changes: 1 addition & 2 deletions assets/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ export function mergeResources<const Ts extends readonly I18nResources[]>(
}>> = {}
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<Resource>)[] = []): {
(): AsyncOrSync<Resource>
Expand Down
1 change: 1 addition & 0 deletions sources/modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ export class EditDataModal<T extends object> 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)
}

Expand Down
2 changes: 2 additions & 0 deletions sources/obsidian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export abstract class ResourceComponent<T> extends Component {
try {
loading = this.load0()
} catch (error) {
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
loading = Promise.reject(error)
}
(async (): Promise<void> => {
Expand Down Expand Up @@ -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() }
})
Expand Down
10 changes: 7 additions & 3 deletions sources/settings-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export abstract class AdvancedSettingTab<S extends PluginContext
() => { this.onUnload() },
))
})
.catch(error => { activeSelf(this.containerEl).console.error(error) })
.catch((error: unknown) => {
activeSelf(this.containerEl).console.error(error)
})
}

public display(): void {
Expand Down Expand Up @@ -105,6 +107,7 @@ export abstract class AdvancedSettingTab<S extends PluginContext
setTextToEnum(
langs,
async value => settings.mutate(settingsM => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
settingsM.language = value || defaults.language
}),
),
Expand Down Expand Up @@ -228,7 +231,7 @@ export abstract class AdvancedSettingTab<S extends PluginContext
this.#onMutate.then(() => {
undoable = true
component.setCta()
}).catch(error => {
}).catch((error: unknown) => {
activeSelf(component.buttonEl).console.error(error)
})
},
Expand Down Expand Up @@ -318,6 +321,7 @@ export abstract class AdvancedSettingTab<S extends PluginContext
try {
resolve(snapshot)
} catch (error) {
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
reject(error)
} finally {
unregister()
Expand All @@ -328,7 +332,7 @@ export abstract class AdvancedSettingTab<S extends PluginContext

protected postMutate(local = false): void {
const { containerEl, context: { localSettings, settings }, ui } = this;
(local ? localSettings : settings).write().catch(error => {
(local ? localSettings : settings).write().catch((error: unknown) => {
activeSelf(containerEl).console.error(error)
})
ui.update()
Expand Down
6 changes: 3 additions & 3 deletions sources/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
{
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions sources/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class EventEmitterLite<A extends readonly unknown[]> {
readonly #listeners: ((...args: A) => unknown)[] = []

public async emit(...args: A): Promise<void> {
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]
Expand Down Expand Up @@ -356,6 +356,7 @@ function deepFreeze0<T>(value: T, freezing: WeakSet<object>): DeepReadonly<T> {
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)
}
}
Expand Down Expand Up @@ -547,7 +548,6 @@ export function lazyProxy<T extends Function | object>(
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)
}
Expand Down Expand Up @@ -623,7 +623,6 @@ export function lazyProxy<T extends Function | object>(
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
Expand Down

0 comments on commit ed91992

Please sign in to comment.