Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 22, 2024
1 parent 983adbb commit d480046
Show file tree
Hide file tree
Showing 23 changed files with 476 additions and 1,189 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

19 changes: 0 additions & 19 deletions .eslintrc.js

This file was deleted.

9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"printWidth": 120,
"semi": false,
"singleQuote": true,
"useTabs": true,
"endOfLine": "lf"
}
26 changes: 8 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,27 @@
"webui"
],
"scripts": {
"postinstall": "./node_modules/.bin/husky install",
"postinstall": "husky",
"dev": "yarn workspace satellite dev",
"dev:electron": "yarn workspace satellite dev-electron",
"dev:webui": "yarn workspace webui dev",
"build": "yarn workspaces foreach --all run build",
"lint:raw": "run eslint --ext .ts --ext .js --ext .tsx --ext .jsx",
"lint": "run lint:raw .",
"license-validate": "sofie-licensecheck",
"dist": "run build && zx tools/build_electron.mjs",
"eslint": "./node_modules/.bin/eslint",
"prettier": "./node_modules/.bin/prettier",
"lint-staged": "./node_modules/.bin/lint-staged"
"dist": "run build && zx tools/build_electron.mjs"
},
"devDependencies": {
"@sofie-automation/code-standard-preset": "~2.5.2",
"@tsconfig/node18": "^18.2.2",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"typescript": "~5.2",
"zx": "^7.2.3"
},
"engines": {
"node": "^18.15"
"node": "^18.18"
},
"resolutions": {
"node-hid": "npm:@julusian/[email protected]"
},
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json",
"lint-staged": {
"*.{css,json,md,scss}": [
"prettier --write"
],
"*.{ts,tsx,js,jsx}": [
"yarn lint --fix"
]
},
"packageManager": "[email protected]"
}
1 change: 1 addition & 0 deletions satellite/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
53 changes: 53 additions & 0 deletions satellite/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// module.exports = {
// extends: '../node_modules/@sofie-automation/code-standard-preset/eslint/main',

// overrides: [
// {
// files: ['*.ts'],
// rules: {
// 'node/no-missing-import': 'off',
// 'node/no-unpublished-import': 'off',
// },
// },
// ],
// settings: {
// jest: {
// // we don't use jest so don't care about the rules
// version: 'latest',
// },
// },
// }

module.exports = {
root: true,
env: { es2020: true },
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'plugin:prettier/recommended',
],
ignorePatterns: ['dist', '.eslintrc.js'],
parser: '@typescript-eslint/parser',
parserOptions: { sourceType: 'module', ecmaVersion: 2023, project: './tsconfig.json' },
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_(.+)' }],
'no-extra-semi': 'off',
'node/no-unsupported-features/es-syntax': ['error', { ignores: ['modules'] }],
// 'no-use-before-define': 'off',
// 'no-warning-comments': ['error', { terms: ['nocommit', '@nocommit', '@no-commit'] }],
'node/no-missing-import': 'off',
'node/no-unpublished-import': 'off', // because of electron dependencies
'@typescript-eslint/require-await': 'off', // too much noise

'@typescript-eslint/restrict-template-expressions': 'off', // TODO temporary
'@typescript-eslint/no-unsafe-return': 'off', // TODO temporary
'@typescript-eslint/no-explicit-any': 'off', // TODO temporary
'@typescript-eslint/no-unsafe-member-access': 'off', // TODO temporary
'@typescript-eslint/no-unsafe-assignment': 'off', // TODO temporary
},
}
22 changes: 14 additions & 8 deletions satellite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,34 @@
"build": "rimraf dist && run build:main",
"build:main": "tsc -p tsconfig.build.json",
"build:electron": "electron-builder --publish=never",
"eslint": "./node_modules/.bin/eslint",
"prettier": "./node_modules/.bin/prettier",
"lint-staged": "./node_modules/.bin/lint-staged"
"lint:raw": "eslint --ext .ts --ext .js --ext .tsx --ext .jsx",
"lint": "run lint:raw ."
},
"devDependencies": {
"@electron/notarize": "^2.2.1",
"@sofie-automation/eslint-plugin": "^0.1.1",
"@types/eslint": "^8",
"@types/koa": "^2.14.0",
"@types/koa-router": "^7.4.8",
"@types/koa-static": "^4.0.4",
"@types/node": "^18.19.14",
"@types/node-hid": "^1.3.4",
"@types/semver": "^7.5.6",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"cross-env": "^7.0.3",
"electron": "25.9.8",
"electron-builder": "^24.12.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.3",
"rimraf": "^5.0.5",
"ts-node": "^10.9.2",
"typescript": "~4.9.5"
"ts-node": "^10.9.2"
},
"engines": {
"node": "^18.15"
"node": "^18.18"
},
"dependencies": {
"@elgato-stream-deck/node": "^6.0.0",
Expand All @@ -60,13 +67,12 @@
"tslib": "^2.6.2",
"usb": "^2.11.0"
},
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json",
"lint-staged": {
"*.{css,json,md,scss}": [
"prettier --write"
],
"*.{ts,tsx,js,jsx}": [
"run -T lint --fix"
"run lint --fix"
]
},
"build": {
Expand Down
4 changes: 2 additions & 2 deletions satellite/src/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class CardGenerator {
height: number,
pixelFormat: imageRs.PixelFormat,
remoteIp: string,
status: string
status: string,
): Promise<Buffer> {
const iconImage = await this.loadIcon()

Expand All @@ -55,7 +55,7 @@ export class CardGenerator {
iconTargetX,
iconTargetY,
iconTargetSize,
iconTargetSize
iconTargetSize,
)

// draw text
Expand Down
2 changes: 1 addition & 1 deletion satellite/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export class CompanionSatelliteClient extends EventEmitter<CompanionSatelliteCli
props.keysTotal
} KEYS_PER_ROW=${props.keysPerRow} BITMAPS=${
this._supportsBitmapResolution ? props.bitmapSize ?? 0 : props.bitmapSize ? 1 : 0
} COLORS=${props.colours ? 1 : 0} TEXT=${props.text ? 1 : 0}\n`
} COLORS=${props.colours ? 1 : 0} TEXT=${props.text ? 1 : 0}\n`,
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions satellite/src/device-types/infinitton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class InfinittonWrapper implements WrappedDevice {
}
async initDevice(client: CompanionClient, status: string): Promise<void> {
console.log('Registering key events for ' + this.deviceId)
this.#panel.on('down', (key) => client.keyDown(this.deviceId, key))
this.#panel.on('up', (key) => client.keyUp(this.deviceId, key))
this.#panel.on('down', (key: number) => client.keyDown(this.deviceId, key))
this.#panel.on('up', (key: number) => client.keyUp(this.deviceId, key))

// Start with blanking it
await this.blankDevice()
Expand Down
12 changes: 9 additions & 3 deletions satellite/src/device-types/loupedeck-live-s.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { LoupedeckDevice, LoupedeckDisplayId, LoupedeckBufferFormat, LoupedeckModelId } from '@loupedeck/node'
import {
LoupedeckDevice,
LoupedeckDisplayId,
LoupedeckBufferFormat,
LoupedeckModelId,
LoupedeckControlType,
} from '@loupedeck/node'
import * as imageRs from '@julusian/image-rs'
import { CardGenerator } from '../cards'
import { ImageWriteQueue } from '../writeQueue'
Expand Down Expand Up @@ -116,7 +122,7 @@ export class LoupedeckLiveSWrapper implements WrappedDevice {
this.#deck.on('down', (info) => client.keyDown(this.deviceId, convertButtonId(info.type, info.index)))
this.#deck.on('up', (info) => client.keyUp(this.deviceId, convertButtonId(info.type, info.index)))
this.#deck.on('rotate', (info, delta) => {
if (info.type !== 'rotary') return
if (info.type !== LoupedeckControlType.Rotary) return

const id2 = convertButtonId(info.type, info.index)
if (id2 < 90) {
Expand Down Expand Up @@ -240,7 +246,7 @@ export class LoupedeckLiveSWrapper implements WrappedDevice {
width,
height,
0,
0
0,
)
}
})
Expand Down
12 changes: 9 additions & 3 deletions satellite/src/device-types/loupedeck-live.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { LoupedeckDevice, LoupedeckDisplayId, LoupedeckBufferFormat, LoupedeckModelId } from '@loupedeck/node'
import {
LoupedeckDevice,
LoupedeckDisplayId,
LoupedeckBufferFormat,
LoupedeckModelId,
LoupedeckControlType,
} from '@loupedeck/node'
import * as imageRs from '@julusian/image-rs'
import { CardGenerator } from '../cards'
import { ImageWriteQueue } from '../writeQueue'
Expand Down Expand Up @@ -135,7 +141,7 @@ export class LoupedeckLiveWrapper implements WrappedDevice {
this.#deck.on('down', (info) => client.keyDown(this.deviceId, convertButtonId(info.type, info.index, true)))
this.#deck.on('up', (info) => client.keyUp(this.deviceId, convertButtonId(info.type, info.index, true)))
this.#deck.on('rotate', (info, delta) => {
if (info.type !== 'rotary') return
if (info.type !== LoupedeckControlType.Rotary) return

const id2 = convertButtonId(info.type, info.index, false)
if (id2 < 90) {
Expand Down Expand Up @@ -244,7 +250,7 @@ export class LoupedeckLiveWrapper implements WrappedDevice {
width,
height,
0,
0
0,
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion satellite/src/device-types/razer-stream-controller-x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class RazerStreamControllerXWrapper implements WrappedDevice {
width,
height,
0,
0
0,
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion satellite/src/device-types/streamdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class StreamDeckWrapper implements WrappedDevice {
buffer,
inputRes,
inputRes,
imageRs.PixelFormat.Rgb
imageRs.PixelFormat.Rgb,
)
.scale(encoderSize.height, encoderSize.height)
.toBuffer(imageRs.PixelFormat.Rgb)
Expand Down
2 changes: 1 addition & 1 deletion satellite/src/device-types/xencelabs-quick-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class QuickKeysWrapper implements WrappedDevice {
}
async setBrightness(percent: number): Promise<void> {
const opts = Object.values<XencelabsQuickKeysDisplayBrightness | string>(
XencelabsQuickKeysDisplayBrightness
XencelabsQuickKeysDisplayBrightness,
).filter((k): k is XencelabsQuickKeysDisplayBrightness => typeof k === 'number')

const perStep = 100 / (opts.length - 1)
Expand Down
24 changes: 12 additions & 12 deletions satellite/src/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ export class DeviceManager {
},
(e) => {
console.error(`Set brightness: ${e}`)
}
)
},
),
)
client.on(
'clearDeck',
Expand All @@ -126,8 +126,8 @@ export class DeviceManager {
},
(e) => {
console.error(`Clear deck: ${e}`)
}
)
},
),
)
client.on(
'draw',
Expand All @@ -138,8 +138,8 @@ export class DeviceManager {
},
(e) => {
console.error(`Draw: ${e}`)
}
)
},
),
)
client.on(
'newDevice',
Expand All @@ -154,8 +154,8 @@ export class DeviceManager {
},
(e) => {
console.error(`Setup device: ${e}`)
}
)
},
),
)
client.on(
'deviceErrored',
Expand All @@ -173,8 +173,8 @@ export class DeviceManager {
},
(e) => {
console.error(`Failed device: ${e}`)
}
)
},
),
)
}

Expand Down Expand Up @@ -264,7 +264,7 @@ export class DeviceManager {
this.scanIsRunning = true
this.scanPending = false

Promise.allSettled([
void Promise.allSettled([
HID.devicesAsync()
.then(async (devices) => {
for (const device of devices) {
Expand Down Expand Up @@ -321,7 +321,7 @@ export class DeviceManager {
private tryAddLoupedeck(
path: string,
serial: string,
wrapperClass: new (deviceId: string, device: LoupedeckDevice, cardGenerator: CardGenerator) => WrappedDevice
wrapperClass: new (deviceId: string, device: LoupedeckDevice, cardGenerator: CardGenerator) => WrappedDevice,
) {
if (this.canAddDevice(serial)) {
console.log(`adding new device: ${path}`)
Expand Down
Loading

0 comments on commit d480046

Please sign in to comment.