Skip to content

Commit afb41f5

Browse files
committed
Clean up typescript code using eslint
1 parent 7f1d94e commit afb41f5

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function displayNotification(
3131
error: KernelError | null,
3232
lastCellOnly: boolean,
3333
notificationMethods: string[],
34-
sessionContext: ISessionContext | null,
34+
sessionContext: ISessionContext | null
3535
): Promise<void> {
3636
const base = PageConfig.getBaseUrl();
3737
const notificationPayload = {
@@ -60,10 +60,9 @@ async function displayNotification(
6060
if (notificationMethods.includes('browser')) {
6161
new Notification(title, notificationPayload);
6262
}
63-
if ((notificationMethods.includes('ntfy')) && (sessionContext)) {
63+
if (notificationMethods.includes('ntfy') && sessionContext) {
6464
await issueNtfyNotification(title, notificationPayload, sessionContext);
6565
}
66-
6766
}
6867

6968
/**
@@ -82,7 +81,7 @@ async function triggerNotification(
8281
error: KernelError | null,
8382
lastCellOnly: boolean,
8483
notificationMethods: string[],
85-
sessionContext: ISessionContext | null,
84+
sessionContext: ISessionContext | null
8685
) {
8786
const cellEndTime = new Date();
8887
const codeCellModel = cell.model as ICodeCellModel;
@@ -125,7 +124,7 @@ async function triggerNotification(
125124
error,
126125
lastCellOnly,
127126
notificationMethods,
128-
sessionContext,
127+
sessionContext
129128
);
130129
}
131130
}
@@ -159,7 +158,7 @@ const extension: JupyterFrontEndPlugin<void> = {
159158
const manager = app.serviceManager;
160159
const sessionContext = new SessionContext({
161160
sessionManager: manager.sessions as any,
162-
specsManager: manager.kernelspecs,
161+
specsManager: manager.kernelspecs
163162
});
164163

165164
if (settingRegistry) {
@@ -174,7 +173,8 @@ const extension: JupyterFrontEndPlugin<void> = {
174173
.composite as boolean;
175174
cellNumberType = setting.get('cell_number_type').composite as string;
176175
lastCellOnly = setting.get('last_cell_only').composite as boolean;
177-
notificationMethods = setting.get('notification_methods').composite as string[];
176+
notificationMethods = setting.get('notification_methods')
177+
.composite as string[];
178178
};
179179
updateSettings();
180180
setting.changed.connect(updateSettings);
@@ -206,7 +206,7 @@ const extension: JupyterFrontEndPlugin<void> = {
206206
error,
207207
lastCellOnly,
208208
notificationMethods,
209-
sessionContext,
209+
sessionContext
210210
);
211211
}
212212
});
@@ -228,7 +228,7 @@ const extension: JupyterFrontEndPlugin<void> = {
228228
null,
229229
lastCellOnly,
230230
notificationMethods,
231-
sessionContext,
231+
sessionContext
232232
);
233233
}
234234
});

src/ntfy.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,32 @@ export async function ensureSessionContextKernelActivated(
55
sessionContext: ISessionContext
66
): Promise<void> {
77
if (sessionContext.hasNoKernel) {
8-
await sessionContext.initialize()
9-
.then(async (value) => {
8+
await sessionContext
9+
.initialize()
10+
.then(async value => {
1011
if (value) {
1112
const py3kernel = await KernelAPI.startNew({ name: 'python3' });
1213
await sessionContext.changeKernel(py3kernel);
1314
}
1415
})
15-
.catch((reason) => {
16-
console.error(`Failed to initialize the session in jupyterlab-notifications.\n${reason}`);
17-
});;
16+
.catch(reason => {
17+
console.error(
18+
`Failed to initialize the session in jupyterlab-notifications.\n${reason}`
19+
);
20+
});
1821
}
1922
}
2023

2124
export async function issueNtfyNotification(
2225
title: string,
2326
notificationPayload: { body: string },
24-
sessionContext: ISessionContext,
25-
): Promise<Kernel.IShellFuture<KernelMessage.IExecuteRequestMsg, KernelMessage.IExecuteReplyMsg>> {
27+
sessionContext: ISessionContext
28+
): Promise<
29+
Kernel.IShellFuture<
30+
KernelMessage.IExecuteRequestMsg,
31+
KernelMessage.IExecuteReplyMsg
32+
>
33+
> {
2634
const { body } = notificationPayload;
2735
await ensureSessionContextKernelActivated(sessionContext);
2836
if (!sessionContext || !sessionContext.session?.kernel) {

0 commit comments

Comments
 (0)