Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Nov 13, 2023
1 parent 9371926 commit 3b959c7
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 151 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"scripts": {
"build": "rimraf dist && yarn build:main",
"build:main": "tsc -p tsconfig.build.json",
"__test": "jest"
"test": "jest"
},
"files": [
"dist/**"
Expand Down
284 changes: 140 additions & 144 deletions packages/core/src/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,149 +13,145 @@ export interface Product {
productId: number
}


export const PRODUCTS: { [name: string]: Product } = {
"SpaceNavigator": literal<Product>({
name: "SpaceNavigator",
vendorId: 0x46d,
productId: 0xc626
}),
"SpaceMouse_Wireless": literal<Product>({
name: "SpaceMouse Wireless",
vendorId: 0x256f,
productId: 0xc62e
}),
"SpaceMouse_Wireless_2": literal<Product>({
name: "SpaceMouse Wireless",
vendorId: 0x256f,
productId: 0xc63a
}),
"SpaceNavigator_for_Notebooks": literal<Product>({
name: "SpaceNavigator for Notebooks",
vendorId: 0x46d,
productId: 0xc628
}),
"SpaceMouse_Compact": literal<Product>({
name: "SpaceMouse Compact",
vendorId: 0x256f,
productId: 0xc635
}),
"SpaceMouse_Module": literal<Product>({
name: "SpaceMouse Module",
vendorId: 0x256f,
productId: 0xc636
}),
"SpaceMouse_Pro": literal<Product>({
name: "SpaceMouse Pro",
vendorId: 0x46d,
productId: 0xc62b
}),
"SpaceMouse_Pro_Wireless": literal<Product>({
name: "SpaceMouse Pro Wireless",
vendorId: 0x256f,
productId: 0xc631
}),
"SpaceMouse_Pro_Wireless_2": literal<Product>({
name: "SpaceMouse Pro Wireless",
vendorId: 0x256f,
productId: 0xc638
}),
"LIPARI": literal<Product>({
name: "LIPARI",
vendorId: 0x256f,
productId: 0xc62c
}),
"SpacePilot_PRO": literal<Product>({
name: "SpacePilot PRO",
vendorId: 0x46d,
productId: 0xc629
}),
"SpaceMouse_Enterprise": literal<Product>({
name: "SpaceMouse Enterprise",
vendorId: 0x256f,
productId: 0xc633

}),
"CadMouse": literal<Product>({
name: "CadMouse",
vendorId: 0x256f,
productId: 0xc650
}),
"CadMouse_Wireless": literal<Product>({
name: "CadMouse Wireless",
vendorId: 0x256f,
productId: 0xc651
}),
"CadMouse_Pro_Wireless": literal<Product>({
name: "CadMouse Pro Wireless",
vendorId: 0x256f,
productId: 0xc654
}),
"CadMouse_Compact": literal<Product>({
name: "CadMouse Compact",
vendorId: 0x256f,
productId: 0xc655
}),
"CadMouse_Pro": literal<Product>({
name: "CadMouse Pro",
vendorId: 0x256f,
productId: 0xc656
}),
"CadMouse_Pro_Wireless_Left": literal<Product>({
name: "CadMouse Pro Wireless Left",
vendorId: 0x256f,
productId: 0xc657
}),
"CadMouse_Compact_Wireless": literal<Product>({
name: "CadMouse Compact Wireless",
vendorId: 0x256f,
productId: 0xc658
}),
"Cassini": literal<Product>({
name: "Cassini",
vendorId: 0x256f,
productId: 0xc659

}),
"Keyboard_Pro": literal<Product>({
name: "Keyboard Pro",
vendorId: 0x256f,
productId: 0xc664
}),
"Numpad_Pro": literal<Product>({
name: "Numpad Pro",
vendorId: 0x256f,
productId: 0xc665
}),
"Keyboard_Pro_2": literal<Product>({
name: "Keyboard Pro",
vendorId: 0x256f,
productId: 0xc668
}),
"SpaceMouse_Wireless_Receiver": literal<Product>({
name: "SpaceMouse Wireless Receiver",
vendorId: 0x256f,
productId: 0xc62f
}),
"SpaceMouse_Pro_Wireless_Receiver": literal<Product>({
name: "SpaceMouse Pro Wireless Receiver",
vendorId: 0x256f,
productId: 0xc632
}),
"Universal_Receiver": literal<Product>({
name: "Universal Receiver",
vendorId: 0x256f,
productId: 0xc652
}),
"Universal_Receiver_2": literal<Product>({
name: "Universal Receiver 2",
vendorId: 0x256f,
productId: 0xc65a
}),
"Universal_Receiver_2_2": literal<Product>({
name: "Universal Receiver 2",
vendorId: 0x256f,
productId: 0xc65c
})
SpaceNavigator: literal<Product>({
name: 'SpaceNavigator',
vendorId: 0x46d,
productId: 0xc626,
}),
SpaceMouse_Wireless: literal<Product>({
name: 'SpaceMouse Wireless',
vendorId: 0x256f,
productId: 0xc62e,
}),
SpaceMouse_Wireless_2: literal<Product>({
name: 'SpaceMouse Wireless',
vendorId: 0x256f,
productId: 0xc63a,
}),
SpaceNavigator_for_Notebooks: literal<Product>({
name: 'SpaceNavigator for Notebooks',
vendorId: 0x46d,
productId: 0xc628,
}),
SpaceMouse_Compact: literal<Product>({
name: 'SpaceMouse Compact',
vendorId: 0x256f,
productId: 0xc635,
}),
SpaceMouse_Module: literal<Product>({
name: 'SpaceMouse Module',
vendorId: 0x256f,
productId: 0xc636,
}),
SpaceMouse_Pro: literal<Product>({
name: 'SpaceMouse Pro',
vendorId: 0x46d,
productId: 0xc62b,
}),
SpaceMouse_Pro_Wireless: literal<Product>({
name: 'SpaceMouse Pro Wireless',
vendorId: 0x256f,
productId: 0xc631,
}),
SpaceMouse_Pro_Wireless_2: literal<Product>({
name: 'SpaceMouse Pro Wireless',
vendorId: 0x256f,
productId: 0xc638,
}),
LIPARI: literal<Product>({
name: 'LIPARI',
vendorId: 0x256f,
productId: 0xc62c,
}),
SpacePilot_PRO: literal<Product>({
name: 'SpacePilot PRO',
vendorId: 0x46d,
productId: 0xc629,
}),
SpaceMouse_Enterprise: literal<Product>({
name: 'SpaceMouse Enterprise',
vendorId: 0x256f,
productId: 0xc633,
}),
CadMouse: literal<Product>({
name: 'CadMouse',
vendorId: 0x256f,
productId: 0xc650,
}),
CadMouse_Wireless: literal<Product>({
name: 'CadMouse Wireless',
vendorId: 0x256f,
productId: 0xc651,
}),
CadMouse_Pro_Wireless: literal<Product>({
name: 'CadMouse Pro Wireless',
vendorId: 0x256f,
productId: 0xc654,
}),
CadMouse_Compact: literal<Product>({
name: 'CadMouse Compact',
vendorId: 0x256f,
productId: 0xc655,
}),
CadMouse_Pro: literal<Product>({
name: 'CadMouse Pro',
vendorId: 0x256f,
productId: 0xc656,
}),
CadMouse_Pro_Wireless_Left: literal<Product>({
name: 'CadMouse Pro Wireless Left',
vendorId: 0x256f,
productId: 0xc657,
}),
CadMouse_Compact_Wireless: literal<Product>({
name: 'CadMouse Compact Wireless',
vendorId: 0x256f,
productId: 0xc658,
}),
Cassini: literal<Product>({
name: 'Cassini',
vendorId: 0x256f,
productId: 0xc659,
}),
Keyboard_Pro: literal<Product>({
name: 'Keyboard Pro',
vendorId: 0x256f,
productId: 0xc664,
}),
Numpad_Pro: literal<Product>({
name: 'Numpad Pro',
vendorId: 0x256f,
productId: 0xc665,
}),
Keyboard_Pro_2: literal<Product>({
name: 'Keyboard Pro',
vendorId: 0x256f,
productId: 0xc668,
}),
SpaceMouse_Wireless_Receiver: literal<Product>({
name: 'SpaceMouse Wireless Receiver',
vendorId: 0x256f,
productId: 0xc62f,
}),
SpaceMouse_Pro_Wireless_Receiver: literal<Product>({
name: 'SpaceMouse Pro Wireless Receiver',
vendorId: 0x256f,
productId: 0xc632,
}),
Universal_Receiver: literal<Product>({
name: 'Universal Receiver',
vendorId: 0x256f,
productId: 0xc652,
}),
Universal_Receiver_2: literal<Product>({
name: 'Universal Receiver 2',
vendorId: 0x256f,
productId: 0xc65a,
}),
Universal_Receiver_2_2: literal<Product>({
name: 'Universal Receiver 2',
vendorId: 0x256f,
productId: 0xc65c,
}),
}

12 changes: 12 additions & 0 deletions packages/node/src/__tests__/__snapshots__/xkeys.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Unit tests SpaceMouse methods 1`] = `
Object {
"interface": 50726,
"name": "SpaceNavigator",
"productId": 1133,
"vendorId": 1133,
}
`;

exports[`Unit tests SpaceMouse methods 2`] = `Array []`;
1 change: 0 additions & 1 deletion packages/node/src/__tests__/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export function getSentData() {
return sentData
}

export function receiveData(hid: HID.HID, message: number[]) {}
export function handleSpaceMouseMessages(hid: HID.HID, message: number[]) {
// Replies to a few of the messages that are sent to the SpaceMouse

Expand Down
7 changes: 4 additions & 3 deletions packages/node/src/__tests__/xkeys.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as HID from 'node-hid'
import * as HIDMock from '../__mocks__/node-hid'
import { PRODUCTS, Rotation, setupSpaceMouse, SpaceMouse } from '../'
import { PRODUCTS, Rotation, setupSpaceMouse } from '../'
import { getSentData, handleSpaceMouseMessages, resetSentData } from './lib'
import { getMockHIDDevices } from '../__mocks__/node-hid'
import { Translation } from '@spacemouse-lib/core'
Expand All @@ -12,6 +12,7 @@ describe('Unit tests', () => {
const hidDevice = {
vendorId: PRODUCTS['SpaceNavigator'].vendorId,
productId: PRODUCTS['SpaceNavigator'].productId,
interface: 0,
path: 'mockPath',
} as HID.Device

Expand Down Expand Up @@ -58,7 +59,7 @@ describe('Unit tests', () => {
expect(onError).toHaveBeenCalledTimes(0)
expect(rotate).toEqual({
pitch: 50,
roll: -255,
roll: -1,
yaw: 139,
})
// Translation:
Expand All @@ -67,7 +68,7 @@ describe('Unit tests', () => {
expect(translate).toEqual({
x: 27,
y: 21,
z: 94,
z: 350,
})
})
})
2 changes: 1 addition & 1 deletion packages/node/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function setupSpaceMouse(devicePathOrHIDDevice?: HID.Device | HID.H
device = new HID.HID(devicePath)
// deviceInfo is set later
} else {
throw new Error('setupSpaceMouse: invalid arguments')
throw new Error(`setupSpaceMouse: invalid arguments: ${JSON.stringify(devicePathOrHIDDevice)}`)
}

if (!deviceInfo) {
Expand Down
2 changes: 1 addition & 1 deletion packages/webhid-demo/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getOpenedSpaceMice, requestSpaceMice, setupSpaceMouse, SpaceMouse } from 'spaceMouse-webhid'
import { getOpenedSpaceMice, requestSpaceMice, setupSpaceMouse, SpaceMouse } from 'spacemouse-webhid'

function appendLog(str: string) {
const logElm = document.getElementById('log')
Expand Down

0 comments on commit 3b959c7

Please sign in to comment.