Skip to content

Commit

Permalink
Upgraded lint ruleset and cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-holder-revvity committed Aug 14, 2024
1 parent 6d55422 commit f1ae4ee
Show file tree
Hide file tree
Showing 93 changed files with 489 additions and 494 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ module.exports = defineConfig(({ useVue, useNode, useTypeScript }) => {
root: true,
env: { es2023: true },
reportUnusedDisableDirectives: true,
rules: {
// 'n/file-extension-in-import': ['error', 'always']
},
overrides: [
{
files: ['*.cjs'],
Expand Down
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run check
yarn run check
6 changes: 2 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"i18n-ally.localesPaths": [
"src/renderer/locales"
],
"vitest.disableWorkspaceWarning": true
"i18n-ally.localesPaths": ["src/renderer/locales"],
"vitest.disableWorkspaceWarning": true
}
Binary file modified .yarn/install-state.gz
Binary file not shown.
66 changes: 34 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ License as published by the Free Software Foundation, either version 3 of the Li
version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see
You should have received a copy of the GNU General Public License along with this program. If not, see
<https://www.gnu.org/licenses/>.

`SPDX-License-Identifier: GPL-3.0-or-later`
Expand Down Expand Up @@ -48,15 +48,15 @@ supported monitors and switches.

BridgeCmdr uses the following libraries and frameworks are a major part of its makeup.

| Framework/Library | License |
|--------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| [Electron](https://electronjs.org/) | [MIT](https://github.com/electron/electron/blob/master/LICENSE) |
| [Vue.js](https://vuejs.org/) | [MIT](https://github.com/vuejs/vue/blob/master/LICENSE) |
| [Vuetify](https://vuetifyjs.com/) | [MIT](https://github.com/vuetifyjs/vuetify/blob/master/LICENSE.md) |
| [PouchDB](https://pouchdb.com/) | [Apache 2.0](https://github.com/pouchdb/pouchdb/blob/master/LICENSE) |
| [LevelDOWN](https://github.com/Level/leveldown) | [MIT](https://github.com/Level/leveldown/blob/master/LICENSE) |
| [SerialPort](https://serialport.io/) | [MIT](https://github.com/serialport/node-serialport/blob/master/LICENSE) |
| [Vuelidate](https://vuelidate-next.netlify.app/) | [MIT](https://github.com/vuelidate/vuelidate/blob/next/LICENSE) |
| Framework/Library | License |
| ------------------------------------------------ | ------------------------------------------------------------------------ |
| [Electron](https://electronjs.org/) | [MIT](https://github.com/electron/electron/blob/master/LICENSE) |
| [Vue.js](https://vuejs.org/) | [MIT](https://github.com/vuejs/vue/blob/master/LICENSE) |
| [Vuetify](https://vuetifyjs.com/) | [MIT](https://github.com/vuetifyjs/vuetify/blob/master/LICENSE.md) |
| [PouchDB](https://pouchdb.com/) | [Apache 2.0](https://github.com/pouchdb/pouchdb/blob/master/LICENSE) |
| [LevelDOWN](https://github.com/Level/leveldown) | [MIT](https://github.com/Level/leveldown/blob/master/LICENSE) |
| [SerialPort](https://serialport.io/) | [MIT](https://github.com/serialport/node-serialport/blob/master/LICENSE) |
| [Vuelidate](https://vuelidate-next.netlify.app/) | [MIT](https://github.com/vuelidate/vuelidate/blob/next/LICENSE) |

For a complete list of dependencies and other utilized libraries, see the `package.json` file.
Any other dependencies not listed above or in the package file are dependencies of those packages.
Expand All @@ -71,14 +71,14 @@ The following tools or libraries are used to build BridgeCmdr.

- [TypeScript](https://www.typescriptlang.org/).
- [ESLint](https://eslint.org/), and the following third-party plug-ins;
- [ESLint TypeScript plug-in](https://typescript-eslint.io/),
- [ESLint Import plug-in](https://github.com/benmosher/eslint-plugin-import),
- [ESLint Promise plug-in](https://github.com/xjamundx/eslint-plugin-promise),
- [ESLint Node plug-in](https://github.com/eslint-community/eslint-plugin-n),
- [Vue.js plug-in](https://eslint.vuejs.org/),
- [ESLint TypeScript plug-in](https://typescript-eslint.io/),
- [ESLint Import plug-in](https://github.com/benmosher/eslint-plugin-import),
- [ESLint Promise plug-in](https://github.com/xjamundx/eslint-plugin-promise),
- [ESLint Node plug-in](https://github.com/eslint-community/eslint-plugin-n),
- [Vue.js plug-in](https://eslint.vuejs.org/),
- [Electron Vite](https://evite.netlify.app/), and the following third-party plug-ins;
- [Vue plug-in](https://github.com/vitejs/vite-plugin-vue),
- [Dart Sass](https://sass-lang.com/dart-sass),
- [Vue plug-in](https://github.com/vitejs/vite-plugin-vue),
- [Dart Sass](https://sass-lang.com/dart-sass),
- [Electron Toolkit](https://github.com/alex8088/electron-toolkit).
- [Electron Installer (Debian)](https://github.com/electron-userland/electron-installer-debian).
- [VisualStudio Code](https://code.visualstudio.com/)
Expand All @@ -89,13 +89,14 @@ or in the package file are dependencies of those packages.
### Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) with:
- [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur)
- [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin)
- [Dotenv + Vault](https://marketplace.visualstudio.com/items?itemName=dotenv.dotenv-vscode)
- [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig)
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [Todo Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree)
- [YAML](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)

- [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur)
- [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin)
- [Dotenv + Vault](https://marketplace.visualstudio.com/items?itemName=dotenv.dotenv-vscode)
- [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig)
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [Todo Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree)
- [YAML](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)

#### Type Support for `.vue` Imports in TS

Expand All @@ -104,8 +105,8 @@ TypeScript cannot handle type information for `.vue` imports by default, so we r
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take-Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:

1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.

### Development
Expand All @@ -115,14 +116,15 @@ based operating system is required. The following steps will get you setup on a

1. Install the `build-essential` package; `sudo apt install build-essential git -y`
2. Acquire the source:
- **Preferred**, Fork the [GitHub repository](https://github.com/6XGate/bridgecmdr), you may then issue pull
requests back to the official source code. Also start personal branches from `develop`.
- Download the [source](https://github.com/6XGate/bridgecmdr/archive/develop.zip) and extract it.
- **Preferred**, Fork the [GitHub repository](https://github.com/6XGate/bridgecmdr), you may then issue pull
requests back to the official source code. Also start personal branches from `develop`.
- Download the [source](https://github.com/6XGate/bridgecmdr/archive/develop.zip) and extract it.
3. Open a terminal clone and go to the folder into which source was cloned or extracted.
4. Install the node packages; `npm ci`
5. Build and run the app;
- For hot-reload mode: `npm run dev`
- For product build preview: `npm run preview`

- For hot-reload mode: `npm run dev`
- For product build preview: `npm run preview`

### Docker and ARM support

Expand Down
1 change: 0 additions & 1 deletion electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ npmRebuild: true
publish:
provider: generic
url: http://localplex.home.sleepingcats.org:9001/bridgecmdr/

18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
"docker:run": "docker run --platform=arm -u $UID:$GID -v .:/app -w /app --rm -it bridgecmdr /bin/bash",
"docker:sh": "npm run docker:build && npm run docker:run",
"postinstall": "electron-builder install-app-deps",
"lint:check": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --ignore-path .eslintignore",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore --ignore-path .eslintignore",
"check": "run-p lint:check typecheck",
"fix": "run-s typecheck lint",
"check:prettier": "prettier -cu .",
"check:lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --ignore-path .eslintignore",
"check": "run-p -l typecheck 'check:*'",
"fix:prettier": "prettier -cu --write .",
"fix:lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore --ignore-path .eslintignore",
"fix": "run-s -l typecheck 'fix:*'",
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
"typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false",
"typecheck": "run-p typecheck:node typecheck:web",
"typecheck:test": "vue-tsc --noEmit -p tsconfig.test.json --composite false",
"typecheck:config": "vue-tsc --noEmit -p tsconfig.config.json --composite false",
"typecheck": "run-p -l 'typecheck:*'",
"start": "electron-vite preview",
"watch": "vitest",
"test": "vitest run",
Expand All @@ -35,7 +39,7 @@
"ncu:update": "ncu -u",
"ncu:check": "ncu",
"ncu": "ncu",
"prepare": "husky install"
"prepare": "husky"
},
"repository": "github:6XGate/bridgecmdr",
"keywords": [
Expand All @@ -61,7 +65,7 @@
"@mdi/js": "^7.4.47",
"@mdi/svg": "^7.4.47",
"@sindresorhus/is": "^7.0.0",
"@sixxgate/lint": "^3.1.4",
"@sixxgate/lint": "^3.2.1",
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.5",
"@types/abstract-leveldown": "^7.2.5",
Expand Down
1 change: 1 addition & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@sixxgate/lint/prettier.config.cjs')
10 changes: 5 additions & 5 deletions src/main/drivers/extron/sis.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Logger from 'electron-log'
import { createCommandStream } from '../../helpers/stream.js'
import { defineDriver, kDeviceCanDecoupleAudioOutput, kDeviceSupportsMultipleOutputs } from '../../system/driver.js'
import { createCommandStream } from '../../helpers/stream'
import { defineDriver, kDeviceCanDecoupleAudioOutput, kDeviceSupportsMultipleOutputs } from '../../system/driver'

const extronSisDriver = defineDriver({
enable: true,
Expand All @@ -13,7 +13,7 @@ const extronSisDriver = defineDriver({
}
},
capabilities: kDeviceSupportsMultipleOutputs | kDeviceCanDecoupleAudioOutput,
setup: async uri => {
setup: async (uri) => {
const sendCommand = async (command: string) => {
const connection = await createCommandStream(uri, {
baudRate: 9600,
Expand All @@ -22,10 +22,10 @@ const extronSisDriver = defineDriver({
})

// TODO: Other situation handlers...
connection.on('data', data => {
connection.on('data', (data) => {
Logger.debug(`extronSisDriver: return: ${String(data)}`)
})
connection.on('error', error => {
connection.on('error', (error) => {
Logger.error(`extronSisDriver: ${error.message}`)
})

Expand Down
14 changes: 7 additions & 7 deletions src/main/drivers/sony/rs485.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
kPowerOff,
kPowerOn,
kSetChannel
} from '../../helpers/sonyRs485.js'
import { createCommandStream } from '../../helpers/stream.js'
import { defineDriver, kDeviceHasNoExtraCapabilities } from '../../system/driver.js'
import type { Command, CommandArg } from '../../helpers/sonyRs485.js'
} from '../../helpers/sonyRs485'
import { createCommandStream } from '../../helpers/stream'
import { defineDriver, kDeviceHasNoExtraCapabilities } from '../../system/driver'
import type { Command, CommandArg } from '../../helpers/sonyRs485'

const sonyRs485Driver = defineDriver({
enable: true,
Expand All @@ -22,7 +22,7 @@ const sonyRs485Driver = defineDriver({
}
},
capabilities: kDeviceHasNoExtraCapabilities,
setup: async uri => {
setup: async (uri) => {
const sendCommand = async (command: Command, arg0?: CommandArg, arg1?: CommandArg) => {
const source = createAddress(kAddressAllMonitors, 0)
const destination = createAddress(kAddressAllMonitors, 0)
Expand All @@ -35,10 +35,10 @@ const sonyRs485Driver = defineDriver({
})

// TODO: Other situation handlers...
connection.on('data', data => {
connection.on('data', (data) => {
Logger.debug(`sonyRs485Driver: return: ${String(data)}`)
})
connection.on('error', error => {
connection.on('error', (error) => {
Logger.error(`sonyRs485Driver: ${error.message}`)
})

Expand Down
10 changes: 5 additions & 5 deletions src/main/drivers/tesla-smart/kvm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Logger from 'electron-log'
import { createCommandStream } from '../../helpers/stream.js'
import { defineDriver, kDeviceHasNoExtraCapabilities } from '../../system/driver.js'
import { createCommandStream } from '../../helpers/stream'
import { defineDriver, kDeviceHasNoExtraCapabilities } from '../../system/driver'

const teslaSmartKvmDriver = defineDriver({
enable: true,
Expand All @@ -13,7 +13,7 @@ const teslaSmartKvmDriver = defineDriver({
}
},
capabilities: kDeviceHasNoExtraCapabilities,
setup: async uri => {
setup: async (uri) => {
const sendCommand = async (command: Buffer) => {
const connection = await createCommandStream(uri, {
baudRate: 9600,
Expand All @@ -22,10 +22,10 @@ const teslaSmartKvmDriver = defineDriver({
})

// TODO: Other situation handlers...
connection.on('data', data => {
connection.on('data', (data) => {
Logger.debug(`teslaSmartKvmDriver: return: ${String(data)}`)
})
connection.on('error', error => {
connection.on('error', (error) => {
Logger.error(`teslaSmartKvmDriver: ${error.message}`)
})

Expand Down
10 changes: 5 additions & 5 deletions src/main/drivers/tesla-smart/matrix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Logger from 'electron-log'
import { createCommandStream } from '../../helpers/stream.js'
import { defineDriver, kDeviceSupportsMultipleOutputs } from '../../system/driver.js'
import { createCommandStream } from '../../helpers/stream'
import { defineDriver, kDeviceSupportsMultipleOutputs } from '../../system/driver'

const teslaSmartMatrixDriver = defineDriver({
enable: true,
Expand All @@ -13,7 +13,7 @@ const teslaSmartMatrixDriver = defineDriver({
}
},
capabilities: kDeviceSupportsMultipleOutputs,
setup: async uri => {
setup: async (uri) => {
const sendCommand = async (command: Buffer) => {
const connection = await createCommandStream(uri, {
baudRate: 9600,
Expand All @@ -22,10 +22,10 @@ const teslaSmartMatrixDriver = defineDriver({
})

// TODO: Other situation handlers...
connection.on('data', data => {
connection.on('data', (data) => {
Logger.debug(`teslaSmartMatrixDriver: return: ${String(data)}`)
})
connection.on('error', error => {
connection.on('error', (error) => {
Logger.error(`teslaSmartMatrixDriver: ${error.message}`)
})

Expand Down
10 changes: 5 additions & 5 deletions src/main/drivers/tesla-smart/sdi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Logger from 'electron-log'
import { createCommandStream } from '../../helpers/stream.js'
import { defineDriver, kDeviceHasNoExtraCapabilities } from '../../system/driver.js'
import { createCommandStream } from '../../helpers/stream'
import { defineDriver, kDeviceHasNoExtraCapabilities } from '../../system/driver'

const teslaSmartSdiDriver = defineDriver({
enable: true,
Expand All @@ -13,7 +13,7 @@ const teslaSmartSdiDriver = defineDriver({
}
},
capabilities: kDeviceHasNoExtraCapabilities,
setup: async uri => {
setup: async (uri) => {
const sendCommand = async (command: Buffer) => {
const connection = await createCommandStream(uri, {
baudRate: 9600,
Expand All @@ -22,10 +22,10 @@ const teslaSmartSdiDriver = defineDriver({
})

// TODO: Other situation handlers...
connection.on('data', data => {
connection.on('data', (data) => {
Logger.debug(`teslaSmartSdiDriver: return: ${String(data)}`)
})
connection.on('error', error => {
connection.on('error', (error) => {
Logger.error(`teslaSmartSdiDriver: ${error.message}`)
})

Expand Down
4 changes: 2 additions & 2 deletions src/main/helpers/dbus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ const useDbus = memo(() => {
}

if (type === 'array:string') {
return `array:string:${(arg as string[]).map(v => `"${v}"`).join(',')}`
return `array:string:${(arg as string[]).map((v) => `"${v}"`).join(',')}`
}

if (type.startsWith('array:')) {
return `${type}:${(arg as string[]).map(v => `"${String(v)}"`).join(',')}`
return `${type}:${(arg as string[]).map((v) => `"${String(v)}"`).join(',')}`
}

const match = kDictType.exec(type)
Expand Down
8 changes: 4 additions & 4 deletions src/main/helpers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { z } from 'zod'
import type { Socket, NetConnectOpts, IpcNetConnectOpts, TcpNetConnectOpts } from 'node:net'
import type { Duplex } from 'node:stream'
import type { Simplify } from 'type-fest'
import { toError } from '@/error-handling.js'
import { toError } from '@/error-handling'

export type IpcStreamOptions = Omit<IpcNetConnectOpts, 'path'>

Expand Down Expand Up @@ -70,7 +70,7 @@ async function createSocketStream(options: NetConnectOpts) {

async function close() {
await new Promise<void>((resolve, reject) => {
socket.once('error', e => {
socket.once('error', (e) => {
reject(e)
})
socket.end(() => {
Expand Down Expand Up @@ -108,15 +108,15 @@ async function createNetStream(target: string, options: NetStreamOptions) {

async function createPortStream(path: string, options: PortStreamOptions) {
const port = await new Promise<SerialPort>((resolve, reject) => {
const stream = new SerialPort({ path, ...options }, e => {
const stream = new SerialPort({ path, ...options }, (e) => {
if (e != null) reject(e)
else resolve(stream)
})
})

async function close() {
await new Promise<void>((resolve, reject) => {
port.close(e => {
port.close((e) => {
if (e != null) reject(e)
else resolve()
})
Expand Down
Loading

0 comments on commit f1ae4ee

Please sign in to comment.