Skip to content

Commit

Permalink
Update dependencies and fix eslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kayahr committed Oct 17, 2024
1 parent 6e339e3 commit f142c00
Show file tree
Hide file tree
Showing 14 changed files with 2,481 additions and 1,357 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.json

This file was deleted.

19 changes: 19 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import kayahrConfigs from "@kayahr/eslint-config";
import globals from "globals";

export default [
{
ignores: [
"lib"
]
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
...kayahrConfigs
];
3,719 changes: 2,419 additions & 1,300 deletions package-lock.json

Large diffs are not rendered by default.

41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
"src"
],
"scripts": {
"prepare": "run-s clean build",
"clean": "rimraf lib",
"copyfiles": "copyfiles -u 1 src/**/*.html lib",
"compile": "tsc",
"cspell": "cspell --no-progress",
"lint": "eslint --max-warnings 0 --ext .ts src",
"check": "jest",
"prepare": "npm run clean && npm run compile && npm run copyfiles",
"test": "npm run cspell && npm run lint && npm run check"
"build": "run-s build:*",
"build:compile": "tsc",
"build:copyfiles": "copyfiles -u 1 src/**/*.html lib",
"test": "run-s test:*",
"test:unit": "jest --colors",
"test:spell": "cspell --no-progress --no-summary",
"test:lint": "eslint --max-warnings 0"
},
"jest": {
"projects": [
Expand Down Expand Up @@ -71,30 +72,30 @@
"./main": "./lib/main/electron/TestRunnerMain.js",
"./environment": "./lib/main/electron/Environment.js"
},
"overrides": {
"globals": "^15.11.0"
},
"devDependencies": {
"@kayahr/eslint-config": "2.11.0",
"@types/express": "4.17.21",
"@types/jest": "29.5.12",
"@types/node": "20.14.11",
"@kayahr/eslint-config": "3.1.0",
"@types/express": "5.0.0",
"@types/jest": "29.5.13",
"@types/node": "22.7.6",
"@types/node-ipc": "9.2.3",
"@types/shell-quote": "1.7.5",
"@types/source-map-support": "0.5.10",
"@types/uuid": "10.0.0",
"@typescript-eslint/eslint-plugin": "7.16.1",
"@typescript-eslint/parser": "7.16.1",
"copyfiles": "2.4.1",
"cspell": "8.11.0",
"eslint-plugin-deprecation": "3.0.0",
"eslint-plugin-simple-import-sort": "12.1.1",
"express": "4.19.2",
"cspell": "8.15.3",
"express": "4.21.1",
"npm-run-all": "4.1.5",
"rimraf": "6.0.1",
"typescript": "5.5.3"
"typescript": "5.6.3"
},
"dependencies": {
"@electron/remote": "^2.1.2",
"@jest/console": "^29.7.0",
"@jest/transform": "^29.7.0",
"electron": "^31.2.1",
"electron": "^33.0.1",
"jest": "^29.7.0",
"jest-docblock": "^29.7.0",
"jest-haste-map": "^29.7.0",
Expand All @@ -109,7 +110,7 @@
"shell-quote": "^1.8.1",
"source-map-support": "^0.5.21",
"throat": "^6.0.2",
"tslib": "^2.6.3",
"tslib": "^2.8.0",
"uuid": "^10.0.0"
}
}
4 changes: 2 additions & 2 deletions src/main/electron/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const origRunInContext = Script.prototype.runInContext;
* replaces the script run code. So we hack into the `script.runInContext` method instead to redirect it to
* `script.runInThisContext` when environment returns the special [[RUN_IN_THIS_CONTEXT]] context.
*/
Script.prototype.runInContext = function(context, options): unknown {
Script.prototype.runInContext = function (context, options): unknown {
if (context === RUN_IN_THIS_CONTEXT) {
return this.runInThisContext(options);
} else {
Expand All @@ -39,7 +39,7 @@ Script.prototype.runInContext = function(context, options): unknown {
* @returns The jest global object.
*/
function createGlobal(): Global.Global {
const jestGlobal: typeof globalThis & { [ "__coverage__" ] ?: unknown } = global;
const jestGlobal: typeof globalThis & { [ "__coverage__" ]?: unknown } = global;
jestGlobal["__coverage__"] = {};
return jestGlobal as Global.Global;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/electron/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface ElectronEnvironmentOptions {
* @see https://www.electronjs.org/docs/latest/api/app#appdisablehardwareacceleration
*/
disableHardwareAcceleration?: boolean;
}
};
}

/** The default electron switches. */
Expand Down
14 changes: 6 additions & 8 deletions src/main/electron/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function registerProcessListener(eventName: string, cb: NodeJS.BeforeExitListene
REGISTERED_PROCESS_EVENTS_MAP.set(eventName, cb);
}

function registerProcessListeners(cleanup: Function): void {
function registerProcessListeners(cleanup: () => void): void {
registerProcessListener("SIGINT", () => {
cleanup();
process.exit(130);
Expand All @@ -134,7 +134,7 @@ function registerProcessListeners(cleanup: Function): void {
});
}

const DISPOSABLES = new Set<Function>();
const DISPOSABLES = new Set<() => void>();

export default abstract class TestRunner extends CallbackTestRunner {
private readonly globalConfig: Config.GlobalConfig;
Expand All @@ -156,12 +156,10 @@ export default abstract class TestRunner extends CallbackTestRunner {
): Promise<void> {
const isWatch = this.globalConfig.watch || this.globalConfig.watchAll;
const { maxWorkers, rootDir } = this.globalConfig;
const concurrency = isWatch
? // because watch is usually used in the background, we'll only use
// half of the regular workers so we don't block other developer
// environment UIs
Math.ceil(Math.min(tests.length, maxWorkers) / 2)
: Math.min(tests.length, maxWorkers);
// because watch is usually used in the background, we'll only use
// half of the regular workers so we don't block other developer
// environment UIs
const concurrency = isWatch ? Math.ceil(Math.min(tests.length, maxWorkers) / 2) : Math.min(tests.length, maxWorkers);
const target = this.getTarget();

const cleanup = once(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/main/electron/electron_process_injected_code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (options.electron?.disableHardwareAcceleration === true) {
}

// Prevent Electron from closing after last window is destroyed because new ones will be created after that.
app.on("window-all-closed", (e: Event) => e.preventDefault());
app.on("window-all-closed", (e?: Event) => e?.preventDefault());

app.on("ready", async () => {
// electron automatically quits if all windows are destroyed,
Expand Down
2 changes: 1 addition & 1 deletion src/main/electron/rpc/JestWorkerRPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function runInBrowserWindow(testData: IPCTestData): Promise<TestResult> {
resolve(testResult);
});
});
} catch(error) {
} catch (error) {
const testResult = buildFailureTestResult(
testData.path,
error instanceof Error ? error : new Error("" + error),
Expand Down
2 changes: 1 addition & 1 deletion src/main/electron/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async function runTestInternal(
if (typeof environment.getVmContext !== "function") {
console.error(
`Test environment found at "${testEnvironment}" does not export a "getVmContext" method, which is `
+ `mandatory from Jest 27. This method is a replacement for "runScript".`,
+ `mandatory from Jest 27. This method is a replacement for "runScript".`
);
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/electron/utils/get_electron_bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getElectronBin(from: string): string {
try {
// first try to resolve from the `rootDir` of the project
return resolve(require.resolve("electron", { paths: [ from ] }), "../cli.js");
} catch (error) {
} catch {
// default to electron included in this package's dependencies
return resolve(require.resolve("electron"), "../cli.js");
}
Expand Down
13 changes: 6 additions & 7 deletions src/main/rpc/RPCProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import { makeUniqServerId } from "../core/utils";
import { INITIALIZE_MESSAGE, JSONRPC_EVENT_NAME } from "./constants";
import { parseResponse, serializeRequest } from "./jsonrpc";

export type SpawnFn = ({ serverID }: { serverID: string}) => ChildProcess;
export type SpawnFn = ({ serverID }: { serverID: string }) => ChildProcess;

export interface SpawnNode {
useBabel?: boolean;
initFile: string;
}

interface RequestError {
code: number,
message: string,
data?: string
code: number;
message: string;
data?: string;
}

function getBabelNodeBin(): string {
Expand Down Expand Up @@ -54,8 +54,7 @@ export class RPCProcess<Methods> {
private readonly spawnFn: SpawnFn;
public remote: Methods;
private socket: Socket | null = null;
private pendingRequests: Record<string, {
resolve: (data: unknown) => void, reject: (error: RequestError) => void }>;
private pendingRequests: Record<string, { resolve: (data: unknown) => void, reject: (error: RequestError) => void }>;
private subProcess?: ChildProcess;

public constructor(spawn: SpawnFn | SpawnNode) {
Expand Down Expand Up @@ -102,7 +101,7 @@ export class RPCProcess<Methods> {
try {
// Kill whole process group with negative PID (See `man kill`)
process.kill(-this.subProcess.pid, "SIGKILL");
} catch (e) {
} catch {
// Ignored
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/rpc/jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface ResponseError {
}

export interface Response {
jsonrpc: string,
jsonrpc: string;
id: string;
result?: unknown;
error?: ResponseError;
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES2020",
"lib": [ "ES2020", "ES2020.Symbol.WellKnown", "DOM" ],
"target": "ES2022",
"lib": [ "ES2022", "DOM" ],
"module": "CommonJS",
"moduleResolution": "Node",
"rootDir": "src",
Expand Down

0 comments on commit f142c00

Please sign in to comment.