fix(utils/index): little fix (lint)

This commit is contained in:
JellyBrick
2023-11-28 10:44:48 +09:00
parent b8f6dd2584
commit 8d06dcc7b6

View File

@ -86,12 +86,14 @@ export const startPlugin = <Config extends PluginConfig>(
if (!lifecycle) return null; if (!lifecycle) return null;
try { try {
// HACK: for bind 'this' to context
const defContext = def[options.ctx]; const defContext = def[options.ctx];
if (defContext && typeof defContext !== 'function') { if (defContext && typeof defContext !== 'function') {
Object.entries(defContext).forEach(([key, value]) => { Object.entries(defContext).forEach(([key, value]) => {
if (typeof value === 'function') {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
if (typeof value === 'function')
defContext[key as keyof typeof defContext] = value.bind(defContext); defContext[key as keyof typeof defContext] = value.bind(defContext);
}
}); });
} }
@ -101,14 +103,14 @@ export const startPlugin = <Config extends PluginConfig>(
); );
console.log( console.log(
`[YTMusic] Executed ${id}::${options.ctx} in ${ '[YTMusic]', `Executed ${id}::${options.ctx} in ${
performance.now() - start performance.now() - start
} ms`, } ms`,
); );
return true; return true;
} catch (err) { } catch (err) {
console.error(`[YTMusic] Failed to start ${id}::${options.ctx}`); console.error('[YTMusic]', `Failed to start ${id}::${options.ctx}`);
console.trace(err); console.trace(err);
return false; return false;
} }
@ -132,14 +134,14 @@ export const stopPlugin = <Config extends PluginConfig>(
); );
console.log( console.log(
`[YTMusic] Executed ${id}::${options.ctx} in ${ '[YTMusic]', `Executed ${id}::${options.ctx} in ${
performance.now() - start performance.now() - start
} ms`, } ms`,
); );
return true; return true;
} catch (err) { } catch (err) {
console.error(`[YTMusic] Failed to execute ${id}::${options.ctx}`); console.error('[YTMusic]', `Failed to execute ${id}::${options.ctx}`);
console.trace(err); console.trace(err);
return false; return false;
} }