Skip to content

Commit

Permalink
Fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cipi1965 committed Jul 24, 2024
1 parent 790ddd2 commit 83e3bd6
Show file tree
Hide file tree
Showing 24 changed files with 121 additions and 125 deletions.
8 changes: 7 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import eslint from '@eslint/js'
import tselint from 'typescript-eslint'
import importPlugin from 'eslint-plugin-import'
import globals from 'globals'

export default tselint.config(
{
ignores: [".webpack/", ".vite/"],
},
{
plugins: {
import: importPlugin
},
extends: [
eslint.configs.recommended,
...tselint.configs.recommended,
Expand All @@ -17,7 +21,9 @@ export default tselint.config(
...globals.node,
}
},
rules:
rules: {
"import/extensions": ["error", "always"]
},
settings: {
"import/resolver": {
node: {
Expand Down
36 changes: 17 additions & 19 deletions src/main/App.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
import NDI from "./Remotes/NDI";
import addDefaultEvents from "./Utilities/addDefaultEvents";
import addIpcHandles from "./Utilities/addIpcHandles";
import {enableDevMode, isDev} from "./Utilities/dev";
import BrowserWinHandler from "./Utilities/BrowserWinHandler";
import createMainWindow from "./mainWindow";
import setMenu from "./Utilities/setMenu";
import NDI from "./Remotes/NDI.ts";
import addDefaultEvents from "./Utilities/addDefaultEvents.ts";
import addIpcHandles from "./Utilities/addIpcHandles.ts";
import {enableDevMode, isDev} from "./Utilities/dev.ts";
import BrowserWinHandler from "./Utilities/BrowserWinHandler.ts";
import createMainWindow from "./mainWindow.ts";
import setMenu from "./Utilities/setMenu.js";
import {app, BrowserWindow, screen, Tray, Menu, nativeImage, dialog} from "electron";
import {
CloseAction,
DEFAULT_CLOSE_ACTION,
DEFAULT_NDI_ENABLED,
DEFAULT_OSC_ENABLED,
DEFAULT_OSC_PORT,
DEFAULT_START_HIDDEN,
DEFAULT_STORE,
DEFAULT_WEBSERVER_ENABLED,
DEFAULT_WEBSERVER_PORT,
} from "../common/config";
import HTTP from "./Remotes/HTTP";
import {OSC} from "./Remotes/OSC";
import {IpcTimerController} from "./Remotes/IpcTimerController";
import {applyMigrations} from "./Migrations/applyMigrations";
} from "../common/config.ts";
import HTTP from "./Remotes/HTTP.ts";
import {OSC} from "./Remotes/OSC.ts";
import {IpcTimerController} from "./Remotes/IpcTimerController.ts";
import macosTrayIcon from "../icons/tray/TrayTemplate.png"
import macOsTrayIcon2x from "../icons/tray/TrayTemplate@2x.png"
import otherOsTrayIcon from "../icons/icon.ico"
import path from "path";
import * as process from "node:process";
import {Config} from "./Utilities/Config";
import {TimersOrchestrator} from "./Utilities/TimersOrchestrator";
import {Config} from "./Utilities/Config.ts";
import {TimersOrchestrator} from "./Utilities/TimersOrchestrator.ts";

// To be packaged, otherwise it doesn't work
console.log(macOsTrayIcon2x)
Expand Down Expand Up @@ -79,14 +76,14 @@ export class CountdownApp {
))
}

appIcon.on('right-click', (event, bounds) => {
appIcon.on('right-click', () => {
const contextMenu = Menu.buildFromTemplate([
{label: 'Quit', role: 'quit'}
])

appIcon.popUpContextMenu(contextMenu);
})
appIcon.on('click', (event, bounds) => {
appIcon.on('click', () => {
if (!this.mainWindowHandler.browserWindow.isVisible()) {
this.mainWindowHandler.browserWindow.show()
} else {
Expand All @@ -112,7 +109,7 @@ export class CountdownApp {
event.preventDefault()

switch (this.config.settings.closeAction ?? DEFAULT_CLOSE_ACTION) {
case CloseAction.Ask:
case CloseAction.Ask: {
const result = await dialog.showMessageBox({
message: "Choose an action",
checkboxLabel: "Don't ask again",
Expand All @@ -138,6 +135,7 @@ export class CountdownApp {
break;
}
break;
}
case CloseAction.Hide:
browserWindow.hide()
break;
Expand Down
2 changes: 1 addition & 1 deletion src/main/Migrations/MergeOpacityToBackgroundColor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseMigration} from "./BaseMigration";
import {BaseMigration} from "./BaseMigration.ts";

export class MergeOpacityToBackgroundColor implements BaseMigration {
migrate(oldConfig: { [key: string]: unknown }): { [key: string]: unknown } {
Expand Down
4 changes: 2 additions & 2 deletions src/main/Migrations/MoveBlackAtResetToContentAtReset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BaseMigration} from "./BaseMigration";
import {ContentAtReset} from "../../common/config";
import {BaseMigration} from "./BaseMigration.ts";
import {ContentAtReset} from "../../common/config.ts";

export class MoveBlackAtResetToContentAtReset implements BaseMigration {
migrate(oldConfig: { [key: string]: unknown }): { [key: string]: unknown } {
Expand Down
72 changes: 36 additions & 36 deletions src/main/Migrations/MoveSettingsToWindow.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
import {BaseMigration} from "./BaseMigration";
import {CloseAction, CountdownStore} from "../../common/config";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import {BaseMigration} from "./BaseMigration.ts";
import {CloseAction} from "../../common/config.ts";

export class MoveSettingsToWindow implements BaseMigration {
migrate(oldConfig: { [key: string]: unknown }): { [key: string]: unknown } {
const settings = oldConfig.settings as {[key: string]: unknown};

if (oldConfig.version as number >= 2) return oldConfig

const newConfig: CountdownStore = {
return {
version: 2,
settings: {
presets: settings.presets as any,
presets: settings.presets,
remote: {
webServerEnabled: settings.webServerEnabled as any,
webServerPort: settings.webServerPort as any,
ndiEnabled: settings.ndiEnabled as any,
ndiAlpha: settings.ndiAlpha as any,
oscEnabled: settings.oscEnabled as any,
oscPort: settings.oscPort as any,
webServerEnabled: settings.webServerEnabled,
webServerPort: settings.webServerPort,
ndiEnabled: settings.ndiEnabled,
ndiAlpha: settings.ndiAlpha,
oscEnabled: settings.oscEnabled,
oscPort: settings.oscPort,
},
setWindowAlwaysOnTop: settings.setWindowAlwaysOnTop as any,
closeAction: settings.closeAction as any ?? CloseAction.Ask,
startHidden: settings.startHidden as any ?? false,
setWindowAlwaysOnTop: settings.setWindowAlwaysOnTop,
closeAction: settings.closeAction ?? CloseAction.Ask,
startHidden: settings.startHidden ?? false,
timers: [{
yellowAtOption: settings.yellowAtOption as any,
yellowAtMinutes: settings.yellowAtMinutes as any,
yellowAtPercent: settings.yellowAtPercent as any,
timerDuration: settings.timerDuration as any,
setTimeLive: settings.setTimeLive as any,
stopTimerAtZero: settings.stopTimerAtZero as any,
yellowAtOption: settings.yellowAtOption,
yellowAtMinutes: settings.yellowAtMinutes,
yellowAtPercent: settings.yellowAtPercent,
timerDuration: settings.timerDuration,
setTimeLive: settings.setTimeLive,
stopTimerAtZero: settings.stopTimerAtZero,
windows: [{
alwaysOnTop: settings.timerAlwaysOnTop as any,
bounds: oldConfig.window as any,
alwaysOnTop: settings.timerAlwaysOnTop,
bounds: oldConfig.window,
show: {
...(settings.show as any),
hours: settings.showHours as any,
...(settings.show),
hours: settings.showHours,
},
messageBoxFixedHeight: settings.messageBoxFixedHeight as any,
contentAtReset: settings.contentAtReset as any,
messageBoxFixedHeight: settings.messageBoxFixedHeight,
contentAtReset: settings.contentAtReset,
colors: {
background: settings.backgroundColor as any,
resetBackground: settings.resetBackgroundColor as any,
text: settings.textColor as any,
timerFinishedText: settings.timerFinishedTextColor as any,
clock: settings.clockColor as any,
clockText: settings.clockTextColor as any,
background: settings.backgroundColor,
resetBackground: settings.resetBackgroundColor,
text: settings.textColor,
timerFinishedText: settings.timerFinishedTextColor,
clock: settings.clockColor,
clockText: settings.clockTextColor,
},
pulseAtZero: settings.pulseAtZero as any,
use12HourClock: settings.use12HourClock as any,
pulseAtZero: settings.pulseAtZero,
use12HourClock: settings.use12HourClock,
}]
}]
}
}

return newConfig as any;
};
}

}
2 changes: 1 addition & 1 deletion src/main/Migrations/RemoveFont.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseMigration} from "./BaseMigration";
import {BaseMigration} from "./BaseMigration.ts";

export class RemoveFont implements BaseMigration {
migrate(oldConfig: { [key: string]: unknown }): { [key: string]: unknown } {
Expand Down
10 changes: 5 additions & 5 deletions src/main/Migrations/applyMigrations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MergeOpacityToBackgroundColor} from "./MergeOpacityToBackgroundColor";
import {BaseMigration} from "./BaseMigration";
import {MoveBlackAtResetToContentAtReset} from "./MoveBlackAtResetToContentAtReset";
import {RemoveFont} from "./RemoveFont";
import {MoveSettingsToWindow} from "./MoveSettingsToWindow";
import {MergeOpacityToBackgroundColor} from "./MergeOpacityToBackgroundColor.ts";
import {BaseMigration} from "./BaseMigration.ts";
import {MoveBlackAtResetToContentAtReset} from "./MoveBlackAtResetToContentAtReset.ts";
import {RemoveFont} from "./RemoveFont.ts";
import {MoveSettingsToWindow} from "./MoveSettingsToWindow.ts";

const migrations: BaseMigration[] = [
new MergeOpacityToBackgroundColor,
Expand Down
7 changes: 4 additions & 3 deletions src/main/Remotes/HTTP.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fastify, {FastifyInstance, RequestGenericInterface} from 'fastify';
import FastifyWebSocket from '@fastify/websocket';
import {BrowserWindow, ipcMain} from "electron";
import {TimerEngineWebSocketUpdate} from "../../common/TimerInterfaces";
import {TimersOrchestrator} from "../Utilities/TimersOrchestrator";
import {TimerEngineWebSocketUpdate} from "../../common/TimerInterfaces.ts";
import {TimersOrchestrator} from "../Utilities/TimersOrchestrator.ts";
import {WebSocket} from "ws";

const secondsPerMinute = 60;
const secondsPerHour = secondsPerMinute * 60;
Expand Down Expand Up @@ -122,7 +123,7 @@ export default class HTTP {
if (!this.fastifyServer.websocketServer) {
return;
}
this.fastifyServer.websocketServer.clients.forEach(function each(client: any) {
this.fastifyServer.websocketServer.clients.forEach(function each(client: WebSocket) {
if (client.readyState === 1) {
client.send(JSON.stringify(payload))
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/Remotes/IpcTimerController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {ipcMain} from "electron";
import {TimerEngine} from "../TimerEngine";
import {IpcTimerCommand, IpcTimerCommandName} from "../../common/IpcInterfaces";
import {IpcTimerCommand, IpcTimerCommandName} from "../../common/IpcInterfaces.ts";
import IpcMainInvokeEvent = Electron.IpcMainInvokeEvent;
import {TimersOrchestrator} from "../Utilities/TimersOrchestrator";
import {TimersOrchestrator} from "../Utilities/TimersOrchestrator.ts";


export class IpcTimerController {
Expand Down
2 changes: 1 addition & 1 deletion src/main/Remotes/NDI.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import grandiose, {FourCC, FrameType, VideoFrame} from "grandiose";
import * as process from "process";
import os from "os";
import ImageBufferAdjustment from "../Utilities/ImageBufferAdjustment";
import ImageBufferAdjustment from "../Utilities/ImageBufferAdjustment.js";
import NativeImage = Electron.NativeImage;

export default class NDIManager {
Expand Down
8 changes: 3 additions & 5 deletions src/main/Remotes/OSC.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {ArgumentType, Server} from "node-osc"; // eslint-disable-line import/no-unresolved
import {TimerEngine} from "../TimerEngine";
import {TimersOrchestrator} from "../Utilities/TimersOrchestrator";
import * as timers from "node:timers";
import {ArgumentType, Server} from "node-osc";
import {TimersOrchestrator} from "../Utilities/TimersOrchestrator.ts";

const secondsPerMinute = 60;
const secondsPerHour = secondsPerMinute * 60;
Expand All @@ -10,7 +8,7 @@ export class OSC {
isRunning = false;
oscServer: Server = null;
port: number = null;
timersOrchestrator: TimersOrchestrator = null;
timersOrchestrator: TimersOrchestrator = null
constructor(port: number, timersOrchestrator: TimersOrchestrator) {
this.port = port;
this.timersOrchestrator = timersOrchestrator;
Expand Down
8 changes: 4 additions & 4 deletions src/main/TimerEngine.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Timer} from "./Utilities/Timer";
import {Timer} from "./Utilities/Timer.ts";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import duration from "dayjs/plugin/duration.js";
import {
MessageUpdateCallback,
UpdateCallback,
WebSocketUpdateCallback
} from "../common/TimerInterfaces";
import {DEFAULT_SET_TIME_LIVE, DEFAULT_STOP_TIMER_AT_ZERO, DEFAULT_YELLOW_AT_OPTION} from "../common/config";
} from "../common/TimerInterfaces.ts";
import {DEFAULT_SET_TIME_LIVE, DEFAULT_STOP_TIMER_AT_ZERO, DEFAULT_YELLOW_AT_OPTION} from "../common/config.ts";
dayjs.extend(duration);

export interface TimerEngineOptions {
Expand Down
15 changes: 8 additions & 7 deletions src/main/Utilities/Config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CountdownSettings, CountdownStore, DEFAULT_STORE} from "../../common/config";
import {CountdownSettings, DEFAULT_STORE} from "../../common/config.ts";
import Store from "electron-store";
import {applyMigrations} from "../Migrations/applyMigrations";
import {applyMigrations} from "../Migrations/applyMigrations.ts";
import {getProperty, setProperty} from "dot-prop";


Expand All @@ -15,17 +15,18 @@ export class Config {
}

constructor(updatedConfig: () => void) {
const newConfig = applyMigrations(this.store.get(null));
this.store.set(newConfig);
this.updatedConfig = updatedConfig
const newConfig = applyMigrations(this.store.get(null))
this.store.set(newConfig)

this._settings = this.store.get('settings')
}

set(key: string, value: any) {
set(key: string, value: unknown) {
if (key) {
setProperty(this._settings, key, value)
} else {
this._settings = value
this._settings = value as CountdownSettings
}
this.store.set('settings', this._settings)
if (this.updatedConfig) {
Expand All @@ -34,7 +35,7 @@ export class Config {
return this._settings
}

get(key?: string): any {
get(key?: string): unknown {
if (!key) return this._settings
return getProperty(this._settings, key)
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/Utilities/Timer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AdjustingInterval from "./AdjustingInterval";
import {DEFAULT_TIMER_DURATION} from "../../common/config";
import AdjustingInterval from "./AdjustingInterval.ts";
import {DEFAULT_TIMER_DURATION} from "../../common/config.ts";

export class Timer {
interval: number;
Expand Down
Loading

0 comments on commit 83e3bd6

Please sign in to comment.