Skip to content

Commit 67f1ad9

Browse files
committed
fix lint errors
1 parent e1edb1e commit 67f1ad9

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

src/index.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ const extension: JupyterFrontEndPlugin<void> = {
1515
optional: [ISettingRegistry],
1616
activate: async (app: JupyterFrontEnd, settingRegistry: ISettingRegistry) => {
1717
checkBrowserNotificationSettings();
18-
var enabled = false;
19-
var minimumCellExecutionTime = 60;
20-
var reportCellExecutionTime = true;
21-
var reportCellNumber = true;
18+
let enabled = false;
19+
let minimumCellExecutionTime = 60;
20+
let reportCellExecutionTime = true;
21+
let reportCellNumber = true;
2222
if (settingRegistry) {
2323
const setting = await settingRegistry.load(extension.id);
2424
const updateSettings = (): void => {
2525
enabled = setting.get('enabled').composite as boolean;
26-
minimumCellExecutionTime = setting.get('minimum_cell_execution_time').composite as number;
27-
reportCellExecutionTime = setting.get('report_cell_execution_time').composite as boolean;
28-
reportCellNumber = setting.get('report_cell_number').composite as boolean;
26+
minimumCellExecutionTime = setting.get('minimum_cell_execution_time')
27+
.composite as number;
28+
reportCellExecutionTime = setting.get('report_cell_execution_time')
29+
.composite as boolean;
30+
reportCellNumber = setting.get('report_cell_number')
31+
.composite as boolean;
2932
};
3033
updateSettings();
3134
setting.changed.connect(updateSettings);
@@ -40,12 +43,19 @@ const extension: JupyterFrontEndPlugin<void> = {
4043
{},
4144
metadata.get('execution') as any
4245
);
43-
const cellStartTime = new Date(executionMetadata['shell.execute_reply.started']);
44-
const cellEndTime = new Date(executionMetadata['shell.execute_reply']);
46+
const cellStartTime = new Date(
47+
executionMetadata['shell.execute_reply.started']
48+
);
49+
const cellEndTime = new Date(
50+
executionMetadata['shell.execute_reply']
51+
);
4552
const diff = new Date(<any>cellEndTime - <any>cellStartTime);
4653
if (diff.getSeconds() >= minimumCellExecutionTime) {
47-
var notificationPayload = {"icon": "/static/favicon.ico", "body": ""};
48-
var message = "";
54+
const notificationPayload = {
55+
icon: '/static/favicon.ico',
56+
body: ''
57+
};
58+
let message = '';
4959
const cellDuration = diff.toISOString().substr(11, 8);
5060
const cellNumber = notebook.activeCellIndex;
5161
if (reportCellNumber && reportCellExecutionTime) {
@@ -59,8 +69,10 @@ const extension: JupyterFrontEndPlugin<void> = {
5969
new Notification('Notebook Cell Completed!', notificationPayload);
6070
}
6171
} else {
62-
alert('Notebook Cell Timing needs to be enabled for Jupyterlab Notifications to work. ' +
63-
'Please go to Settings -> Advanced Settings Editor -> Notebook and update setting to {"recordTiming": true}');
72+
alert(
73+
'Notebook Cell Timing needs to be enabled for Jupyterlab Notifications to work. ' +
74+
'Please go to Settings -> Advanced Settings Editor -> Notebook and update setting to {"recordTiming": true}'
75+
);
6476
}
6577
}
6678
});

src/settings.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
function checkNotificationPromise(): boolean {
22
try {
33
Notification.requestPermission().then();
4-
} catch(e) {
4+
} catch (e) {
55
return false;
66
}
77
return true;
88
}
9-
9+
1010
function handlePermission(permission: string): void {
11-
if (permission == 'granted') {
12-
alert("Browser Notifications are allowed. (^_^)b");
11+
if (permission === 'granted') {
12+
alert('Browser Notifications are allowed. (^_^)b');
1313
} else {
14-
alert("Browser Notifications are not allowed. Please update your browser settings to allow notifications.");
14+
alert(
15+
'Browser Notifications are not allowed. Please update your browser settings to allow notifications.'
16+
);
1517
}
1618
}
1719

1820
export function checkBrowserNotificationSettings(): void {
1921
if (!('Notification' in window)) {
20-
alert("This browser does not support notifications.");
22+
alert('This browser does not support notifications.');
2123
} else if (Notification.permission !== 'granted') {
22-
if(checkNotificationPromise()) {
23-
Notification.requestPermission().then((permission) => {
24+
if (checkNotificationPromise()) {
25+
Notification.requestPermission().then(permission => {
2426
handlePermission(permission);
2527
});
2628
} else {
27-
Notification.requestPermission(function(permission) {
29+
Notification.requestPermission(permission => {
2830
handlePermission(permission);
2931
});
3032
}

0 commit comments

Comments
 (0)