style: add no-misused-promises rule (#3547)

Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
LongYinan
2023-08-04 16:08:10 +08:00
committed by GitHub
parent f8e49ee3be
commit 5795020403
19 changed files with 130 additions and 74 deletions

View File

@@ -115,7 +115,11 @@ function startPollingSecondaryDB(db: WorkspaceSQLiteDB) {
const secondaryDB = new SecondaryWorkspaceSQLiteDB(path, db);
return new Observable<SecondaryWorkspaceSQLiteDB>(subscriber => {
subscriber.next(secondaryDB);
return () => secondaryDB.destroy();
return () => {
secondaryDB.destroy().catch(err => {
subscriber.error(err);
});
};
});
}),
switchMap(secondaryDB => {

View File

@@ -38,7 +38,7 @@ app.on('second-instance', () => {
);
});
app.on('open-url', async (_, _url) => {
app.on('open-url', (_, _url) => {
// todo: handle `affine://...` urls
});
@@ -54,7 +54,11 @@ app.on('window-all-closed', () => {
/**
* @see https://www.electronjs.org/docs/v14-x-y/api/app#event-activate-macos Event: 'activate'
*/
app.on('activate', restoreOrCreateWindow);
app.on('activate', () => {
restoreOrCreateWindow().catch(err => {
console.error(err);
});
});
/**
* Create app window when background process will be ready

View File

@@ -34,7 +34,7 @@ export function getGoogleOauthCode() {
logger.error('Failed to open external url', e);
reject(e);
});
const handleOpenUrl = async (_: any, url: string) => {
const handleOpenUrl = (_: any, url: string) => {
const mainWindow = BrowserWindow.getAllWindows().find(
w => !w.isDestroyed()
);

View File

@@ -99,7 +99,9 @@ export const registerUpdater = async () => {
});
autoUpdater.forceDevUpdateConfig = isDev;
app.on('activate', async () => {
await checkForUpdates(false);
app.on('activate', () => {
checkForUpdates(false).catch(err => {
console.error(err);
});
});
};

View File

@@ -19,10 +19,15 @@ const mainThread = AsyncCall<{
channel: new MessageEventChannel(parentPort),
});
// eslint-disable-next-line @typescript-eslint/no-misused-promises
globalThis.console.log = mainThread.log;
// eslint-disable-next-line @typescript-eslint/no-misused-promises
globalThis.console.error = mainThread.log;
// eslint-disable-next-line @typescript-eslint/no-misused-promises
globalThis.console.info = mainThread.log;
// eslint-disable-next-line @typescript-eslint/no-misused-promises
globalThis.console.debug = mainThread.log;
// eslint-disable-next-line @typescript-eslint/no-misused-promises
globalThis.console.warn = mainThread.log;
// eslint-disable-next-line @typescript-eslint/no-var-requires