From 4f29224e657fbf425c00c3c7150f91fe1aed8817 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Wed, 19 Jun 2024 10:22:36 +0200 Subject: [PATCH] build: add all files to linting --- angular.json | 7 +- electron/dbus.ts | 173 ---------------------------------------------- package-lock.json | 35 ++++++++++ package.json | 1 + 4 files changed, 42 insertions(+), 174 deletions(-) delete mode 100644 electron/dbus.ts diff --git a/angular.json b/angular.json index 41c3a374c..31156dd92 100644 --- a/angular.json +++ b/angular.json @@ -214,7 +214,12 @@ "builder": "@angular-eslint/builder:lint", "options": { "cache": true, - "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] + "lintFilePatterns": [ + "src/**/*.ts", + "src/**/*.html", + "e2e/**/*.ts", + "electron/**/*.ts" + ] } } } diff --git a/electron/dbus.ts b/electron/dbus.ts deleted file mode 100644 index 97773a161..000000000 --- a/electron/dbus.ts +++ /dev/null @@ -1,173 +0,0 @@ -'use strict'; - -import { IPC } from './shared-with-frontend/ipc-events.const'; -import { error, log } from 'electron-log/main'; - -const errorHandler = require('./error-handler-with-frontend-inform'); -const mainWinMod = require('./main-window'); - -// only optionally require dbus -let isDBusError = false; -let dbus; -try { - dbus = require('dbus-native'); -} catch (e) { - log('NOTE: Continuing without DBUS'); - error(e); - isDBusError = true; -} - -const CONFIG = require('./CONFIG'); -const serviceName = CONFIG.D_BUS_ID; - -const interfaceName = serviceName; -const objectPath = '/' + serviceName.replace(/\./g, '/'); - -let sessionBus; -let ifaceDesc; -let iface; - -// eslint-disable-next-line prefer-arrow/prefer-arrow-functions -function init(params): void { - sessionBus = dbus.sessionBus(); - - // Check the connection was successful - if (!sessionBus) { - isDBusError = true; - errorHandler(`DBus: Could not connect to the DBus session bus.`); - } - - sessionBus.requestName(serviceName, 0x4, (e, retCode) => { - // If there was an error, warn user and fail - if (e) { - isDBusError = true; - errorHandler( - `DBus: Could not request service name ${serviceName}, the error was: ${e}.`, - ); - } - - // Return code 0x1 means we successfully had the name - if (retCode === 1) { - log(`Successfully requested service name '${serviceName}'!`); - proceed(); - /* Other return codes means various errors, check here - (https://dbus.freedesktop.org/doc/api/html/group__DBusShared.html#ga37a9bc7c6eb11d212bf8d5e5ff3b50f9) for more - information - */ - } else { - isDBusError = true; - errorHandler( - `DBus: Failed to request service name '${serviceName}'.Check what return code '${retCode}' means.`, - ); - } - }); - - // Function called when we have successfully got the service name we wanted - // eslint-disable-next-line prefer-arrow/prefer-arrow-functions - function proceed(): void { - // First, we need to create our interface description (here we will only expose method calls) - ifaceDesc = { - name: interfaceName, - methods: { - // Simple types - markAsDone: [], - startTask: [], - pauseTask: [], - showApp: [], - quitApp: [], - }, - properties: {}, - signals: { - taskChanged: ['ss', 'task_id', 'task_text'], - pomodoroUpdate: ['bxx', 'is_on_break', 'session_time_left', 'session_total_time'], - }, - }; - - // eslint-disable-next-line prefer-arrow/prefer-arrow-functions - function checkMainWin(): void { - const mainWin = mainWinMod.getWin(); - if (!mainWin) { - errorHandler('DBus: mainWin not ready'); - } - } - - // Then we need to create the interface implementation (with actual functions) - iface = { - markAsDone: () => { - checkMainWin(); - const mainWin = mainWinMod.getWin(); - mainWin.webContents.send(IPC.TASK_MARK_AS_DONE); - }, - startTask: () => { - checkMainWin(); - const mainWin = mainWinMod.getWin(); - mainWin.webContents.send(IPC.TASK_START); - }, - pauseTask: () => { - checkMainWin(); - const mainWin = mainWinMod.getWin(); - mainWin.webContents.send(IPC.TASK_PAUSE); - }, - showApp: () => { - params.showApp(); - }, - quitApp: () => { - params.quitApp(); - }, - emit: () => { - // no nothing, as usual - }, - }; - - // Now we need to actually export our interface on our object - sessionBus.exportInterface(iface, objectPath, ifaceDesc); - - // Say our service is ready to receive function calls (you can use `gdbus call` to make function calls) - log('Interface exposed to DBus, ready to receive function calls!'); - } -} - -let isErrorShownOnce = false; - -if (!isDBusError) { - module.exports = { - init, - setTask: (taskId, taskText) => { - // fail silently to prevent hundreds of error messages - if (isDBusError || isErrorShownOnce) { - return; - } - - if (iface) { - errorHandler('DBus: interface not ready yet'); - isErrorShownOnce = true; - } else { - iface.emit('taskChanged', taskId + '', taskText + ''); - } - }, - updatePomodoro: (isOnBreak, currentSessionTime, currentSessionInitialTime) => { - // fail silently to prevent hundreds of error messages - if (isDBusError || isErrorShownOnce) { - return; - } - - if (iface) { - iface.emit( - 'pomodoroUpdate', - isOnBreak ? 1 : 0, - currentSessionTime, - currentSessionInitialTime, - ); - } else { - errorHandler('DBus: interface not ready yet'); - isErrorShownOnce = true; - } - }, - }; -} else { - module.exports = { - init: () => {}, - setTask: () => {}, - updatePomodoro: () => {}, - }; -} diff --git a/package-lock.json b/package-lock.json index f535db98d..dd93ca5b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "@angular-eslint/builder": "^18.0.1", "@angular-eslint/eslint-plugin": "^18.0.1", "@angular-eslint/eslint-plugin-template": "^18.0.1", + "@angular-eslint/schematics": "^18.0.1", "@angular-eslint/template-parser": "^18.0.1", "@angular/animations": "^18.0.3", "@angular/cdk": "^18.0.3", @@ -652,6 +653,25 @@ "typescript": "*" } }, + "node_modules/@angular-eslint/schematics": { + "version": "18.0.1", + "resolved": "https://registry.npmjs.org/@angular-eslint/schematics/-/schematics-18.0.1.tgz", + "integrity": "sha512-G9PgFrjyvBaQR8enMnP2scnQDLk99GMpifh3voiOmdEkxaQHRWqhCWncV7GATwpXDzeyj9J9XT9iHGJjnZTpJQ==", + "dev": true, + "dependencies": { + "@angular-eslint/eslint-plugin": "18.0.1", + "@angular-eslint/eslint-plugin-template": "18.0.1", + "@nx/devkit": "^19.0.6", + "ignore": "5.3.1", + "nx": "^19.0.6", + "semver": "7.6.2", + "strip-json-comments": "3.1.1" + }, + "peerDependencies": { + "@angular-devkit/core": ">= 18.0.0 < 19.0.0", + "@angular-devkit/schematics": ">= 18.0.0 < 19.0.0" + } + }, "node_modules/@angular-eslint/template-parser": { "version": "18.0.1", "resolved": "https://registry.npmjs.org/@angular-eslint/template-parser/-/template-parser-18.0.1.tgz", @@ -27703,6 +27723,21 @@ "axobject-query": "4.0.0" } }, + "@angular-eslint/schematics": { + "version": "18.0.1", + "resolved": "https://registry.npmjs.org/@angular-eslint/schematics/-/schematics-18.0.1.tgz", + "integrity": "sha512-G9PgFrjyvBaQR8enMnP2scnQDLk99GMpifh3voiOmdEkxaQHRWqhCWncV7GATwpXDzeyj9J9XT9iHGJjnZTpJQ==", + "dev": true, + "requires": { + "@angular-eslint/eslint-plugin": "18.0.1", + "@angular-eslint/eslint-plugin-template": "18.0.1", + "@nx/devkit": "^19.0.6", + "ignore": "5.3.1", + "nx": "^19.0.6", + "semver": "7.6.2", + "strip-json-comments": "3.1.1" + } + }, "@angular-eslint/template-parser": { "version": "18.0.1", "resolved": "https://registry.npmjs.org/@angular-eslint/template-parser/-/template-parser-18.0.1.tgz", diff --git a/package.json b/package.json index 5d0e58428..62e999f58 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "@angular-eslint/builder": "^18.0.1", "@angular-eslint/eslint-plugin": "^18.0.1", "@angular-eslint/eslint-plugin-template": "^18.0.1", + "@angular-eslint/schematics": "^18.0.1", "@angular-eslint/template-parser": "^18.0.1", "@angular/animations": "^18.0.3", "@angular/cdk": "^18.0.3",