From 33a9c0181a2b675e2ffd22929ea52ce63afbe299 Mon Sep 17 00:00:00 2001 From: "Michael J. Roberts" Date: Sun, 24 Apr 2022 20:39:42 +0100 Subject: [PATCH] chore(useBluetoothAPI): applied suggested lint fixes --- packages/core/useBluetooth/index.md | 23 ++++++++++++----------- packages/core/useBluetooth/index.ts | 3 ++- pnpm-lock.yaml | 8 ++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/core/useBluetooth/index.md b/packages/core/useBluetooth/index.md index 861b514e905..8721e12f974 100644 --- a/packages/core/useBluetooth/index.md +++ b/packages/core/useBluetooth/index.md @@ -19,14 +19,14 @@ N.B. This API is not available in Web Workers (not exposed via WorkerNavigator). ```ts import { useBluetooth } from '@vueuse/core' -const { +const { isSupported, isConnected, device, requestDevice, - server + server, } = useBluetooth({ - acceptAllDevices: true + acceptAllDevices: true, }) ``` @@ -49,32 +49,32 @@ Here, we use the characteristicvaluechanged event listener to handle reading bat ```ts import { pausableWatch, useBluetooth } from '@vueuse/core' -const { +const { isSupported, isConnected, device, requestDevice, - server + server, } = useBluetooth({ acceptAllDevices: true, optionalServices: [ - "battery_service" - ] + 'battery_service', + ], }) const batteryPercent = ref() const isGettingBatteryLevels = ref(false) -const getBatteryLevels = async () => { +const getBatteryLevels = async() => { isGettingBatteryLevels.value = true // Get the battery service: - const batteryService = await server.getPrimaryService("battery_service") + const batteryService = await server.getPrimaryService('battery_service') // Get the current battery level const batteryLevelCharacteristic = await batteryService.getCharacteristic( - "battery_level" + 'battery_level', ) // Listen to when characteristic value changes on `characteristicvaluechanged` event: @@ -89,7 +89,8 @@ const getBatteryLevels = async () => { } const { stop } = pausableWatch(isConnected, (newIsConnected) => { - if (!newIsConnected || !server.value || isGettingBatteryLevels.value) return + if (!newIsConnected || !server.value || isGettingBatteryLevels.value) + return // Attempt to get the battery levels of the device: getBatteryLevels() // We only want to run this on the initial connection, as we will use a event listener to handle updates: diff --git a/packages/core/useBluetooth/index.ts b/packages/core/useBluetooth/index.ts index ef6df3f0a40..b85e678e29d 100644 --- a/packages/core/useBluetooth/index.ts +++ b/packages/core/useBluetooth/index.ts @@ -63,7 +63,8 @@ export function useBluetooth(options?: UseBluetoothOptions) { async function requestDevice(): Promise { // This is the function can only be called if Bluetooth API is supported: - if (!isSupported) return + if (!isSupported) + return // Reset any errors we currently have: error.value = null diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0797fca7627..0bf9d1993bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2676,14 +2676,14 @@ packages: resolution: {integrity: sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==} dev: true - /@types/web-bluetooth/0.0.12: - resolution: {integrity: sha512-Q4sUrowpylCOWjUWFtNwkNBHQUnCL8y44Iq2ZLtVMAuAGIwPSXa3kqIvu2LwXoc2d1jyaaw4Bg354degHrsADw==} - dev: true - /@types/unist/2.0.6: resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==} dev: true + /@types/web-bluetooth/0.0.12: + resolution: {integrity: sha512-Q4sUrowpylCOWjUWFtNwkNBHQUnCL8y44Iq2ZLtVMAuAGIwPSXa3kqIvu2LwXoc2d1jyaaw4Bg354degHrsADw==} + dev: true + /@typescript-eslint/eslint-plugin/5.17.0_689ff565753ecf7c3328c07fad067df5: resolution: {integrity: sha512-qVstvQilEd89HJk3qcbKt/zZrfBZ+9h2ynpAGlWjWiizA7m/MtLT9RoX6gjtpE500vfIg8jogAkDzdCxbsFASQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}