From eb00217d68e4351b64543aee21c6449c3415f5fd Mon Sep 17 00:00:00 2001 From: Nils Kolvenbach Date: Thu, 25 Jul 2024 16:21:11 +0200 Subject: [PATCH] Re-Added lint and typecheck step to CI --- .github/workflows/ci.yml | 6 ++- package.json | 2 +- src/main/index.ts | 69 ++++++++++-------------- src/renderer/src/components/ui/alert.tsx | 34 ++++++------ 4 files changed, 49 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d44c36f..e473523a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,10 @@ jobs: node-version: ${{ matrix.node-version }} - name: Install dependencies run: npm install - # - name: Run linter - # run: npm run lint + - name: Run linter + run: npm run lint + - name: Run typecheck + run: npm run typecheck # - name: Identify misconfigurations and security anti-patterns # uses: doyensec/electronegativity-action@v2 # - name: Upload report diff --git a/package.json b/package.json index 7e1ca81f..263192fb 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "scripts": { "clean": "rimraf ./out && rimraf ./dist", "format": "prettier --write .", - "lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix", + "lint": "eslint ./src --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix", "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", "typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false", "typecheck": "npm run typecheck:node && npm run typecheck:web", diff --git a/src/main/index.ts b/src/main/index.ts index 926d3af7..7467e700 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -72,7 +72,7 @@ class Main { } private onWebContentsCreated( - event: { + _event: { preventDefault: () => void; readonly defaultPrevented: boolean; }, @@ -117,7 +117,7 @@ class Main { // On OS X it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (BrowserWindow.getAllWindows().length === 0) { - this.createWindow('/projects'); + this.createWindow(); } } @@ -132,24 +132,12 @@ class Main { return net.fetch(filePath); }); - // Check in Core if either local or cloud user is set - // If no, show the user the /user/create page - // If yes use this to init core and show /projects - const core = new ElekIoCore({ environment: app.isPackaged ? 'production' : 'development', }); - this.registerIpcMain(core); - - // const user = await core.user.get(); - // let mainWindow: BrowserWindow; - this.createWindow('/'); - // if (user) { - // mainWindow = await this.createWindow('/projects'); - // } else { - // mainWindow = await this.createWindow('/user/create'); - // } + const window = this.createWindow(); + this.registerIpcMain(window, core); } /** @@ -182,10 +170,7 @@ class Main { return windowSize; } - private createWindow( - path: string, - options?: BrowserWindowConstructorOptions - ) { + private createWindow(options?: BrowserWindowConstructorOptions) { const { width, height } = this.getWindowSize(); // Set defaults if missing @@ -263,41 +248,41 @@ class Main { return window; } - private registerIpcMain(core: ElekIoCore) { - ipcMain.handle('electron:dialog:showOpenDialog', async (event, args) => { - return await dialog.showOpenDialog(undefined, args); + private registerIpcMain(window: Electron.BrowserWindow, core: ElekIoCore) { + ipcMain.handle('electron:dialog:showOpenDialog', async (_event, args) => { + return await dialog.showOpenDialog(window, args); }); ipcMain.handle('core:user:get', async () => { return await core.user.get(); }); - ipcMain.handle('core:user:set', async (event, args) => { + ipcMain.handle('core:user:set', async (_event, args) => { return await core.user.set(args[0]); }); ipcMain.handle('core:projects:count', async () => { return await core.projects.count(); }); - ipcMain.handle('core:projects:create', async (event, args) => { + ipcMain.handle('core:projects:create', async (_event, args) => { return await core.projects.create(args[0]); }); - ipcMain.handle('core:projects:list', async (event, args) => { + ipcMain.handle('core:projects:list', async (_event, args) => { return await core.projects.list(args[0]); }); - ipcMain.handle('core:projects:read', async (event, args) => { + ipcMain.handle('core:projects:read', async (_event, args) => { return await core.projects.read(args[0]); }); - ipcMain.handle('core:projects:update', async (event, args) => { + ipcMain.handle('core:projects:update', async (_event, args) => { return await core.projects.update(args[0]); }); - ipcMain.handle('core:projects:delete', async (event, args) => { + ipcMain.handle('core:projects:delete', async (_event, args) => { return await core.projects.delete(args[0]); }); - ipcMain.handle('core:assets:list', async (event, args) => { + ipcMain.handle('core:assets:list', async (_event, args) => { return await core.assets.list(args[0]); }); - ipcMain.handle('core:assets:create', async (event, args) => { + ipcMain.handle('core:assets:create', async (_event, args) => { return await core.assets.create(args[0]); }); - ipcMain.handle('core:assets:delete', async (event, args) => { + ipcMain.handle('core:assets:delete', async (_event, args) => { return await core.assets.delete(args[0]); }); // ipcMain.handle('core:snapshots:list', async (event, args) => { @@ -312,34 +297,34 @@ class Main { // ipcMain.handle('core:snapshots:commitHistory', async (event, args) => { // return await core.snapshots.commitHistory(args[0]); // }); - ipcMain.handle('core:collections:list', async (event, args) => { + ipcMain.handle('core:collections:list', async (_event, args) => { return await core.collections.list(args[0]); }); - ipcMain.handle('core:collections:create', async (event, args) => { + ipcMain.handle('core:collections:create', async (_event, args) => { return await core.collections.create(args[0]); }); - ipcMain.handle('core:collections:read', async (event, args) => { + ipcMain.handle('core:collections:read', async (_event, args) => { return await core.collections.read(args[0]); }); - ipcMain.handle('core:collections:update', async (event, args) => { + ipcMain.handle('core:collections:update', async (_event, args) => { return await core.collections.update(args[0]); }); - ipcMain.handle('core:collections:delete', async (event, args) => { + ipcMain.handle('core:collections:delete', async (_event, args) => { return await core.collections.delete(args[0]); }); - ipcMain.handle('core:entries:list', async (event, args) => { + ipcMain.handle('core:entries:list', async (_event, args) => { return await core.entries.list(args[0]); }); - ipcMain.handle('core:entries:create', async (event, args) => { + ipcMain.handle('core:entries:create', async (_event, args) => { return await core.entries.create(args[0]); }); - ipcMain.handle('core:entries:read', async (event, args) => { + ipcMain.handle('core:entries:read', async (_event, args) => { return await core.entries.read(args[0]); }); - ipcMain.handle('core:entries:update', async (event, args) => { + ipcMain.handle('core:entries:update', async (_event, args) => { return await core.entries.update(args[0]); }); - ipcMain.handle('core:entries:delete', async (event, args) => { + ipcMain.handle('core:entries:delete', async (_event, args) => { return await core.entries.delete(args[0]); }); // this.handleIpcMain>('core:assets:list', async (event, args) => { diff --git a/src/renderer/src/components/ui/alert.tsx b/src/renderer/src/components/ui/alert.tsx index bac972a5..11f6bdd2 100644 --- a/src/renderer/src/components/ui/alert.tsx +++ b/src/renderer/src/components/ui/alert.tsx @@ -1,23 +1,23 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from 'react'; +import { cva, type VariantProps } from 'class-variance-authority'; -import { cn } from "@renderer/util" +import { cn } from '@renderer/util'; const alertVariants = cva( - "relative w-full rounded-lg border border-zinc-200 px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-zinc-950 [&>svg~*]:pl-7 dark:border-zinc-800 dark:[&>svg]:text-zinc-50", + 'relative w-full rounded-lg border border-zinc-200 px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-zinc-950 [&>svg~*]:pl-7 dark:border-zinc-800 dark:[&>svg]:text-zinc-50', { variants: { variant: { - default: "bg-white text-zinc-950 dark:bg-zinc-950 dark:text-zinc-50", + default: 'bg-white text-zinc-950 dark:bg-zinc-950 dark:text-zinc-50', destructive: - "border-red-500/50 text-red-500 dark:border-red-500 [&>svg]:text-red-500 dark:border-red-900/50 dark:text-red-900 dark:dark:border-red-900 dark:[&>svg]:text-red-900", + 'border-red-500/50 text-red-500 dark:border-red-500 [&>svg]:text-red-500 dark:border-red-900/50 dark:text-red-900 dark:dark:border-red-900 dark:[&>svg]:text-red-900', }, }, defaultVariants: { - variant: "default", + variant: 'default', }, } -) +); const Alert = React.forwardRef< HTMLDivElement, @@ -29,8 +29,8 @@ const Alert = React.forwardRef< className={cn(alertVariants({ variant }), className)} {...props} /> -)) -Alert.displayName = "Alert" +)); +Alert.displayName = 'Alert'; const AlertTitle = React.forwardRef< HTMLParagraphElement, @@ -38,11 +38,11 @@ const AlertTitle = React.forwardRef< >(({ className, ...props }, ref) => (
-)) -AlertTitle.displayName = "AlertTitle" +)); +AlertTitle.displayName = 'AlertTitle'; const AlertDescription = React.forwardRef< HTMLParagraphElement, @@ -50,10 +50,10 @@ const AlertDescription = React.forwardRef< >(({ className, ...props }, ref) => (
-)) -AlertDescription.displayName = "AlertDescription" +)); +AlertDescription.displayName = 'AlertDescription'; -export { Alert, AlertTitle, AlertDescription } +export { Alert, AlertTitle, AlertDescription };