Skip to content

Commit

Permalink
refactor: fix ts lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Feb 10, 2024
1 parent 465c7e1 commit 2cf3190
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ module.exports = defineFlatConfig({
"react-hooks": reactHooks,
},
rules: {
...ts.configs.recommended.rules,
"@typescript-eslint/no-var-requires": "off", // electron require

...react.configs.recommended.rules,
...react.configs["jsx-runtime"].rules,
...reactHooks.configs.recommended.rules,
Expand Down
7 changes: 4 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { WinAdapter } from "./main/win";
import { MacosAdapter } from "./main/macos";
import { LinuxAdapter } from "./main/linux";
import { setUpdater, setReporter } from "./main/utils";
import { AppDispatch, AppInfo } from "./renderer/app-context";
import { AppInfo } from "./renderer/app-context";
import { SessionDispatch } from "./renderer/session-context";
import getPort from "get-port";
import { v4 } from "uuid";
Expand Down Expand Up @@ -71,7 +71,7 @@ if (!gotTheLock) {
mainWindow?.webContents.send("session-dispatch", action);
};

app.on("second-instance", (event, commandLine, workingDirectory) => {
app.on("second-instance", () => {
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
Expand Down Expand Up @@ -171,7 +171,7 @@ if (!gotTheLock) {
sp.on("error", (err) => {
dialog.showErrorBox(`Error: ${app.name}`, err.message);
});
sp.on("close", (code) => {
sp.on("close", () => {
// console.log(`child process exited with code ${code}`)
sessionDispatch({ type: "remove", sessionId });
// TODO: Remove temp app
Expand All @@ -181,6 +181,7 @@ if (!gotTheLock) {
(isError = false) =>
(chunk: Buffer) => {
// TODO: stderr colors
console.log(isError);
sessionDispatch({ type: "log", sessionId, text: chunk.toString() });
};

Expand Down
21 changes: 10 additions & 11 deletions src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,19 @@ export const App: React.FC = () => {
}
}
},
async getFilesFromEvent(e: any) {
// Drop
if (e.dataTransfer && e.dataTransfer.files) {
const fileList = e.dataTransfer.files as FileList;
return [...fileList];
}
async getFilesFromEvent(e) {
const files =
// @ts-expect-error no dataTransfer
e.dataTransfer?.files ?? // drop
// @ts-expect-error target type
e.target?.files; // click

// Click
if (e.target && e.target.files) {
const fileList = e.target.files as FileList;
if (files) {
const fileList = files as FileList;
return [...fileList];
} else {
return [];
}

return [];
},
});

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { App } from "./app";
import { AppProvider } from "./app-context";
import { SessionProvider } from "./session-context";

// For debug
(window as any).electron = require("electron");
// @ts-expect-error for debug
window.electron = require("electron");

createRoot(document.getElementById("root")!).render(
<AppProvider>
Expand Down
1 change: 0 additions & 1 deletion src/renderer/session-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
createContext,
useReducer,
} from "react";
import { v4 } from "uuid";

type SessionId = string;
type PageId = string;
Expand Down

0 comments on commit 2cf3190

Please sign in to comment.