Skip to content

Commit ea5fff9

Browse files
authored
Merge pull request #47 from QuantStack/lint
Lint all the things
2 parents 313aadb + 174adb7 commit ea5fff9

29 files changed

Lines changed: 4711 additions & 375 deletions

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build
22

33
on:
44
push:
5-
branches: main
5+
branches: ["main"]
66
pull_request:
7-
branches: '*'
7+
branches: ["*"]
88

99
concurrency:
1010
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

.github/workflows/enforce-label.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/bluetooth-extension/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ const BluetoothSidebarPlugin: JupyterFrontEndPlugin<void> = {
6464
console.log('JupyterLab bluetooth-sidebar plugin is activated!');
6565
const trans = translator.load('jupyterlab');
6666
const { commands } = app;
67-
const openDeviceRegistryDialogLabel = trans.__(
68-
'Add a Device'
69-
);
67+
const openDeviceRegistryDialogLabel = trans.__('Add a Device');
7068
let runningItemsList: Array<IRunningSessions.IRunningItem>;
7169

7270
app.commands.addCommand(CommandIDs.disconnectDevice, {
73-
execute: (args) => {
74-
const selectedDevice= bluetoothManager.deviceList.find((device) => device.native.id === args.deviceID as string);
71+
execute: args => {
72+
const selectedDevice = bluetoothManager.deviceList.find(
73+
device => device.native.id === (args.deviceID as string)
74+
);
7575
if (selectedDevice) {
7676
bluetoothManager.disconnectDevice(selectedDevice);
7777
return selectedDevice;
@@ -83,7 +83,6 @@ const BluetoothSidebarPlugin: JupyterFrontEndPlugin<void> = {
8383
label: trans.__('Disconnect Device')
8484
});
8585

86-
8786
app.commands.addCommand(CommandIDs.openDeviceRegistryDialog, {
8887
execute: async () => {
8988
showDialog({
@@ -107,7 +106,6 @@ const BluetoothSidebarPlugin: JupyterFrontEndPlugin<void> = {
107106
}
108107
});
109108

110-
111109
managers.add({
112110
name: trans.__('Bluetooth Devices'),
113111
supportsMultipleViews: false,
@@ -121,8 +119,7 @@ const BluetoothSidebarPlugin: JupyterFrontEndPlugin<void> = {
121119
commands
122120
)
123121
);
124-
}
125-
);
122+
});
126123
return runningItemsList;
127124
},
128125
shutdownAll: () => {
@@ -152,7 +149,8 @@ const BluetoothSidebarPlugin: JupyterFrontEndPlugin<void> = {
152149

153150
export class DropDownRegistry
154151
extends Widget
155-
implements Dialog.IBodyWidget<string> {
152+
implements Dialog.IBodyWidget<string>
153+
{
156154
constructor(registry: BluetoothManager.DeviceRegistry) {
157155
super();
158156
this._selectList = document.createElement('select');

src/bluetooth/BluetoothDeviceRunningItem.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ import { CommandRegistry } from '@lumino/commands';
88
export const disconnectDevice = 'bluetooth-manager:disconnect-device';
99

1010
export class BluetoothDeviceRunningItem
11-
implements IRunningSessions.IRunningItem {
12-
constructor(device: BluetoothManager.Device, bluetoothManager: BluetoothManager, commands: CommandRegistry) {
11+
implements IRunningSessions.IRunningItem
12+
{
13+
constructor(
14+
device: BluetoothManager.Device,
15+
bluetoothManager: BluetoothManager,
16+
commands: CommandRegistry
17+
) {
1318
this._device = device;
1419
this.bluetoothManager = bluetoothManager;
1520
if (this._device.native.name) {
@@ -24,11 +29,11 @@ export class BluetoothDeviceRunningItem
2429
open() {
2530
const commands = this.commands;
2631
const deviceID = this._device.native.id;
27-
const menu = new Menu({ commands: commands })
32+
const menu = new Menu({ commands: commands });
2833
this._device.contextCommands.map((command: string) => {
29-
menu.addItem({ command: command, args: {deviceID}})
30-
})
31-
menu.addClass('jp-bluetooth-device-running-item-menu')
34+
menu.addItem({ command: command, args: { deviceID } });
35+
});
36+
menu.addClass('jp-bluetooth-device-running-item-menu');
3237
const deviceElement = document.querySelector(`.${this.className}`);
3338
if (deviceElement) {
3439
const rect = deviceElement.getBoundingClientRect();

src/bluetooth/BluetoothManager.ts

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { buildCompleteIdentifier } from '../bluetooth-extension';
55
import { IDisposable } from '@lumino/disposable';
66
import { Dialog, showDialog } from '@jupyterlab/apputils';
77

8-
98
/**
109
* A class used to update the list of connected device and the related signals used to rerender the connected devices section.
1110
*/
@@ -101,29 +100,24 @@ export class BluetoothManager implements IBluetoothManager {
101100
const isWebBluetoothSupported: boolean = navigator.bluetooth ? true : false;
102101
if (isWebBluetoothSupported === false) {
103102
showDialog({
104-
title: ('Error'),
105-
body: (
106-
'Web Bluetooth is not supported on your browser. It works on Chrome and Edge (Firefox and Explorer are not supported). \n Please also check that the Web Bluetooth flag is properly set to enabled in the Chrome flags (chrome://flags/).'
107-
),
108-
buttons: [
109-
Dialog.okButton({ label: ('Close') })
110-
]
103+
title: 'Error',
104+
body: 'Web Bluetooth is not supported on your browser. It works on Chrome and Edge (Firefox and Explorer are not supported). \n Please also check that the Web Bluetooth flag is properly set to enabled in the Chrome flags (chrome://flags/).',
105+
buttons: [Dialog.okButton({ label: 'Close' })]
111106
});
112107
}
113-
return isWebBluetoothSupported
108+
return isWebBluetoothSupported;
114109
}
115110

116111
async requestDevice(
117112
registryItem: IDeviceRegistryItem
118113
): Promise<BluetoothDevice | undefined> {
119-
const isWebBluetoothSupported = await this.checkWebBluetoothSupport()
114+
const isWebBluetoothSupported = await this.checkWebBluetoothSupport();
120115
if (isWebBluetoothSupported) {
121116
const native = await navigator.bluetooth.requestDevice(
122117
registryItem.options
123118
);
124119
return native;
125-
}
126-
else {
120+
} else {
127121
return;
128122
}
129123
}
@@ -146,15 +140,18 @@ export namespace BluetoothManager {
146140
public connected: Signal<this, boolean>;
147141
public disconnected: Signal<this, boolean>;
148142
public isDisposed: boolean;
149-
public contextCommands:Array<string>;
143+
public contextCommands: Array<string>;
150144

151145
constructor(native: BluetoothDevice) {
152146
this.connected = new Signal<this, boolean>(this);
153147
this.disconnected = new Signal<this, boolean>(this);
154148
this.isConnected = false;
155149
this.isDisposed = false;
156150
this.native = native;
157-
this.contextCommands = ['bluetooth-manager:disconnect-device', 'bluetooth-manager:add-lego-movehub-control-panel']
151+
this.contextCommands = [
152+
'bluetooth-manager:disconnect-device',
153+
'bluetooth-manager:add-lego-movehub-control-panel'
154+
];
158155
}
159156

160157
async connectAndGetAllServices(): Promise<
@@ -164,40 +161,45 @@ export namespace BluetoothManager {
164161
this.isConnected = false;
165162
this.disconnected.emit(true);
166163
});
167-
const server = this.native.gatt
164+
const server = this.native.gatt;
168165
if (server) {
169166
const timeout = 5000;
170167
const connectWithTimeout = new Promise<void>((resolve, reject) => {
171-
const timeoutId = setTimeout(() => {
172-
reject(
173-
new Error('Connection to GATT server timed out'));
168+
const timeoutId = setTimeout(() => {
169+
reject(new Error('Connection to GATT server timed out'));
174170
server.disconnect();
175171
this.dispose();
176172
}, timeout);
177173

178-
server.connect().then(async () => {
179-
clearTimeout(timeoutId);
180-
resolve();
181-
this.isConnected = true;
182-
this.connected.emit(true);
183-
})
184-
.catch((error) => {
174+
server
175+
.connect()
176+
.then(async () => {
177+
clearTimeout(timeoutId);
178+
resolve();
179+
this.isConnected = true;
180+
this.connected.emit(true);
181+
})
182+
.catch(error => {
185183
server.disconnect();
186184
reject(error);
187185
});
188186
});
189-
await connectWithTimeout
187+
await connectWithTimeout;
190188
if (server.connected === true) {
191189
const services = await server.getPrimaryServices();
192190
if (!services || services.length === 0) {
193-
throw new Error('Server exists but no service found on the device.');
194-
} else { return services; }
195-
}
196-
else {
197-
throw new Error('There is no connection to server. No attempt to get a service.')
191+
throw new Error(
192+
'Server exists but no service found on the device.'
193+
);
194+
} else {
195+
return services;
196+
}
197+
} else {
198+
throw new Error(
199+
'There is no connection to server. No attempt to get a service.'
200+
);
198201
}
199-
}
200-
else {
202+
} else {
201203
throw new Error('Server is not defined.');
202204
}
203205
}
@@ -256,7 +258,7 @@ export namespace BluetoothManager {
256258
if (service) {
257259
return service.getCharacteristics();
258260
} else {
259-
throw new Error('The requested service is not available.')
261+
throw new Error('The requested service is not available.');
260262
}
261263
}
262264

@@ -267,7 +269,6 @@ export namespace BluetoothManager {
267269
const service = await this.getService(serviceUUID);
268270
if (service) {
269271
return service.getCharacteristic(characteristicUUID);
270-
271272
} else {
272273
throw new Error('The requested service is not available.');
273274
}

src/bluetooth/icon.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ export const LegoBrickIcon = new LabIcon({
1919
name: '@jupyterlab/bluetooh-manager:bluetooth-lego-brick',
2020
svgstr: LegoBrickSvgstr
2121
});
22-
;
23-
2422
export const GreenCircle = new LabIcon({
2523
name: '@jupyterlab/bluetooh-manager:bluetooth-green-circle',
2624
svgstr: GreenCircleSvgstr

src/movehub-extension/components/BatteryGauge.tsx

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const batteryCustomizationLight = {
3838
lowBatteryColor: 'red',
3939
fontFamily: 'Helvetica',
4040
fontSize: 20,
41-
showPercentage: true // Set to true to show battery percentage
42-
},
41+
showPercentage: true // Set to true to show battery percentage
42+
}
4343
};
4444

4545
const batteryCustomizationDark = {
@@ -72,11 +72,14 @@ const batteryCustomizationDark = {
7272
lowBatteryColor: 'red',
7373
fontFamily: 'Helvetica',
7474
fontSize: 20,
75-
showPercentage: true // Set to true to show battery percentage
76-
},
75+
showPercentage: true // Set to true to show battery percentage
76+
}
7777
};
7878

79-
export default function BatteryComponent({ device, themeManager }: IMoveHubPanelWithThemeProps) {
79+
export default function BatteryComponent({
80+
device,
81+
themeManager
82+
}: IMoveHubPanelWithThemeProps) {
8083
const [deviceState, setDeviceState] = useState<DeviceInfo>(defaultDeviceInfo);
8184
const theme = themeManager.theme;
8285
console.log('theme:', theme);
@@ -106,45 +109,50 @@ export default function BatteryComponent({ device, themeManager }: IMoveHubPanel
106109
const isThemeLight = themeManager.isLight(theme);
107110
return (
108111
<UseSignal signal={themeManager.themeChanged}>
109-
{(): JSX.Element => (
112+
{(): JSX.Element =>
110113
deviceState.batteryLevel !== undefined &&
111-
deviceState.connected === true ? (
114+
deviceState.connected === true ? (
112115
<BatteryGauge
113116
value={deviceState.batteryLevel}
114117
width={'50px'}
115-
customization={isThemeLight ? batteryCustomizationLight : batteryCustomizationDark}
116-
118+
customization={
119+
isThemeLight
120+
? batteryCustomizationLight
121+
: batteryCustomizationDark
122+
}
117123
/>
118124
) : (
119125
<div></div>
120126
)
121-
)}
127+
}
122128
</UseSignal>
123129
);
124130
} else {
125-
return (
126-
deviceState.batteryLevel !== undefined &&
127-
deviceState.connected === true ? (
128-
<BatteryGauge
129-
value={deviceState.batteryLevel}
130-
customization={batteryCustomizationLight}
131-
132-
/>) : (<div></div>)
133-
)
131+
return deviceState.batteryLevel !== undefined &&
132+
deviceState.connected === true ? (
133+
<BatteryGauge
134+
value={deviceState.batteryLevel}
135+
customization={batteryCustomizationLight}
136+
/>
137+
) : (
138+
<div></div>
139+
);
134140
}
135141
}
136142

137143
export class BatteryWidget extends ReactWidget {
138144
public device: MoveHub;
139-
public themeManager: IThemeManager
145+
public themeManager: IThemeManager;
140146

141147
constructor(device: MoveHub, themeManager: IThemeManager) {
142148
super();
143149
this.device = device;
144-
this.themeManager = themeManager
150+
this.themeManager = themeManager;
145151
}
146152

147153
render() {
148-
return <BatteryComponent device={this.device} themeManager={this.themeManager} />;
154+
return (
155+
<BatteryComponent device={this.device} themeManager={this.themeManager} />
156+
);
149157
}
150158
}

0 commit comments

Comments
 (0)