mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-18 13:42:21 +00:00
fix: Fix biome correctness errors
This commit is contained in:
+5
-5
@@ -24,13 +24,13 @@
|
|||||||
"noExplicitAny": "off"
|
"noExplicitAny": "off"
|
||||||
},
|
},
|
||||||
"correctness": {
|
"correctness": {
|
||||||
"noUnusedImports": "off",
|
"noUnusedImports": "warn",
|
||||||
"noUnusedFunctionParameters": "off",
|
"noUnusedFunctionParameters": "warn",
|
||||||
"noUnusedVariables": "off",
|
"noUnusedVariables": "warn",
|
||||||
"noConstructorReturn": "off"
|
"noConstructorReturn": "warn"
|
||||||
},
|
},
|
||||||
"complexity": {
|
"complexity": {
|
||||||
"useLiteralKeys": "off"
|
"useLiteralKeys": "warn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
createWindowPlans,
|
createWindowPlans,
|
||||||
findDuplicates,
|
findDuplicates,
|
||||||
formatInvalidModelError,
|
formatInvalidModelError,
|
||||||
getSessionPath,
|
|
||||||
getWorktreePath,
|
getWorktreePath,
|
||||||
launchModelInWindow,
|
launchModelInWindow,
|
||||||
normalizeModels,
|
normalizeModels,
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ export const closeTool = tool({
|
|||||||
"whether to create archive tags before deleting branches (default: true)",
|
"whether to create archive tags before deleting branches (default: true)",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
async execute(args, context) {
|
async execute(args, _context) {
|
||||||
// In plugin mode, we skip confirmation (force=true) since there's no interactive terminal
|
// In plugin mode, we skip confirmation (force=true) since there's no interactive terminal
|
||||||
const result = await closeMultiModel({
|
const result = await closeMultiModel({
|
||||||
sessionName: args.sessionName,
|
sessionName: args.sessionName,
|
||||||
|
|||||||
+9
-5
@@ -19,7 +19,7 @@ let mockCommandResponses: Record<
|
|||||||
let executedCommands: string[] = [];
|
let executedCommands: string[] = [];
|
||||||
|
|
||||||
function setupMockBun$() {
|
function setupMockBun$() {
|
||||||
const mockFn = mock((strings: TemplateStringsArray, ...values: any[]) => {
|
const mockFn = mock((_strings: TemplateStringsArray, ...values: any[]) => {
|
||||||
const parts = values[0] as string[];
|
const parts = values[0] as string[];
|
||||||
const commandSignature = parts.join(" ");
|
const commandSignature = parts.join(" ");
|
||||||
executedCommands.push(commandSignature);
|
executedCommands.push(commandSignature);
|
||||||
@@ -47,11 +47,11 @@ function restoreOriginalBun$() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("closeMultiModel", () => {
|
describe("closeMultiModel", () => {
|
||||||
let bunMock: ReturnType<typeof setupMockBun$>;
|
let _bunMock: ReturnType<typeof setupMockBun$>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(os, "homedir").mockReturnValue("/home/user");
|
spyOn(os, "homedir").mockReturnValue("/home/user");
|
||||||
bunMock = setupMockBun$();
|
_bunMock = setupMockBun$();
|
||||||
executedCommands = [];
|
executedCommands = [];
|
||||||
mockCommandResponses = {};
|
mockCommandResponses = {};
|
||||||
});
|
});
|
||||||
@@ -153,6 +153,7 @@ describe("closeMultiModel", () => {
|
|||||||
global.Date = class extends OriginalDate {
|
global.Date = class extends OriginalDate {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
// biome-ignore lint/correctness/noConstructorReturn: time-mocking required
|
||||||
return fixedDate;
|
return fixedDate;
|
||||||
}
|
}
|
||||||
toISOString() {
|
toISOString() {
|
||||||
@@ -201,7 +202,7 @@ describe("closeMultiModel", () => {
|
|||||||
|
|
||||||
// Stub readline to return "n"
|
// Stub readline to return "n"
|
||||||
const mockInterface = {
|
const mockInterface = {
|
||||||
question: (q: string, cb: (a: string) => void) => cb("n"),
|
question: (_q: string, cb: (a: string) => void) => cb("n"),
|
||||||
close: () => {},
|
close: () => {},
|
||||||
} as any;
|
} as any;
|
||||||
spyOn(readline, "createInterface").mockImplementation(() => mockInterface);
|
spyOn(readline, "createInterface").mockImplementation(() => mockInterface);
|
||||||
@@ -232,7 +233,7 @@ describe("closeMultiModel", () => {
|
|||||||
|
|
||||||
// Stub readline to simulate user confirming cleanup (answers "y")
|
// Stub readline to simulate user confirming cleanup (answers "y")
|
||||||
const mockInterface = {
|
const mockInterface = {
|
||||||
question: (q: string, cb: (a: string) => void) => cb("y"),
|
question: (_q: string, cb: (a: string) => void) => cb("y"),
|
||||||
close: () => {},
|
close: () => {},
|
||||||
} as any;
|
} as any;
|
||||||
spyOn(readline, "createInterface").mockImplementation(() => mockInterface);
|
spyOn(readline, "createInterface").mockImplementation(() => mockInterface);
|
||||||
@@ -244,6 +245,7 @@ describe("closeMultiModel", () => {
|
|||||||
global.Date = class extends OriginalDate {
|
global.Date = class extends OriginalDate {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
// biome-ignore lint/correctness/noConstructorReturn: time-mocking required
|
||||||
return fixedDate;
|
return fixedDate;
|
||||||
}
|
}
|
||||||
toISOString() {
|
toISOString() {
|
||||||
@@ -310,6 +312,7 @@ describe("closeMultiModel", () => {
|
|||||||
global.Date = class extends OriginalDate {
|
global.Date = class extends OriginalDate {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
// biome-ignore lint/correctness/noConstructorReturn: time-mocking required
|
||||||
return fixedDate;
|
return fixedDate;
|
||||||
}
|
}
|
||||||
toISOString() {
|
toISOString() {
|
||||||
@@ -375,6 +378,7 @@ describe("closeMultiModel", () => {
|
|||||||
global.Date = class extends OriginalDate {
|
global.Date = class extends OriginalDate {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
// biome-ignore lint/correctness/noConstructorReturn: time-mocking required
|
||||||
return fixedDate;
|
return fixedDate;
|
||||||
}
|
}
|
||||||
toISOString() {
|
toISOString() {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ let mockCommandResponses: Record<
|
|||||||
let executedCommands: string[] = [];
|
let executedCommands: string[] = [];
|
||||||
|
|
||||||
function setupMockBun$() {
|
function setupMockBun$() {
|
||||||
const mockFn = mock((strings: TemplateStringsArray, ...values: any[]) => {
|
const mockFn = mock((_strings: TemplateStringsArray, ...values: any[]) => {
|
||||||
const parts = values[0] as string[];
|
const parts = values[0] as string[];
|
||||||
const cmd = parts.join(" ");
|
const cmd = parts.join(" ");
|
||||||
executedCommands.push(cmd);
|
executedCommands.push(cmd);
|
||||||
|
|||||||
+3
-21
@@ -10,24 +10,6 @@ import {
|
|||||||
import * as fs from "node:fs";
|
import * as fs from "node:fs";
|
||||||
import * as os from "node:os";
|
import * as os from "node:os";
|
||||||
import { openMultiModel } from "../src/core/open";
|
import { openMultiModel } from "../src/core/open";
|
||||||
import {
|
|
||||||
createWindowBaseName,
|
|
||||||
createWindowPlans,
|
|
||||||
findDuplicates,
|
|
||||||
formatInvalidModelError,
|
|
||||||
getBinaryName,
|
|
||||||
getSessionPath,
|
|
||||||
getWorktreePath,
|
|
||||||
getWorktreesForSession,
|
|
||||||
launchModelInWindow,
|
|
||||||
levenshtein,
|
|
||||||
normalizeModels,
|
|
||||||
runCommand,
|
|
||||||
sanitizeName,
|
|
||||||
shellQuote,
|
|
||||||
suggestModels,
|
|
||||||
undoWorktree,
|
|
||||||
} from "../src/core/utils";
|
|
||||||
|
|
||||||
const originalBun$: typeof Bun.$ = (globalThis as any).Bun?.$;
|
const originalBun$: typeof Bun.$ = (globalThis as any).Bun?.$;
|
||||||
let mockCommandResponses: Record<
|
let mockCommandResponses: Record<
|
||||||
@@ -37,7 +19,7 @@ let mockCommandResponses: Record<
|
|||||||
let executedCommands: string[] = [];
|
let executedCommands: string[] = [];
|
||||||
|
|
||||||
function setupMockBun$() {
|
function setupMockBun$() {
|
||||||
const mockFn = mock((strings: TemplateStringsArray, ...values: any[]) => {
|
const mockFn = mock((_strings: TemplateStringsArray, ...values: any[]) => {
|
||||||
const parts = values[0] as string[];
|
const parts = values[0] as string[];
|
||||||
const commandSignature = parts.join(" ");
|
const commandSignature = parts.join(" ");
|
||||||
|
|
||||||
@@ -71,12 +53,12 @@ function restoreOriginalBun$() {
|
|||||||
|
|
||||||
describe("multi-model launch", () => {
|
describe("multi-model launch", () => {
|
||||||
let existsSyncMock: ReturnType<typeof spyOn>;
|
let existsSyncMock: ReturnType<typeof spyOn>;
|
||||||
let bunMock: ReturnType<typeof setupMockBun$>;
|
let _bunMock: ReturnType<typeof setupMockBun$>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(os, "homedir").mockReturnValue("/mock/home");
|
spyOn(os, "homedir").mockReturnValue("/mock/home");
|
||||||
existsSyncMock = spyOn(fs, "existsSync").mockReturnValue(false);
|
existsSyncMock = spyOn(fs, "existsSync").mockReturnValue(false);
|
||||||
bunMock = setupMockBun$();
|
_bunMock = setupMockBun$();
|
||||||
executedCommands = [];
|
executedCommands = [];
|
||||||
|
|
||||||
mockCommandResponses = {
|
mockCommandResponses = {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ let mockCommandResponses: Record<
|
|||||||
let executedCommands: string[] = [];
|
let executedCommands: string[] = [];
|
||||||
|
|
||||||
function setupMockBun$() {
|
function setupMockBun$() {
|
||||||
const mockFn = mock((strings: TemplateStringsArray, ...values: any[]) => {
|
const mockFn = mock((_strings: TemplateStringsArray, ...values: any[]) => {
|
||||||
const parts = values[0] as string[];
|
const parts = values[0] as string[];
|
||||||
const cmd = parts.join(" ");
|
const cmd = parts.join(" ");
|
||||||
executedCommands.push(cmd);
|
executedCommands.push(cmd);
|
||||||
|
|||||||
+4
-5
@@ -7,7 +7,6 @@ import {
|
|||||||
spyOn,
|
spyOn,
|
||||||
test,
|
test,
|
||||||
} from "bun:test";
|
} from "bun:test";
|
||||||
import * as fs from "node:fs";
|
|
||||||
import * as os from "node:os";
|
import * as os from "node:os";
|
||||||
import {
|
import {
|
||||||
createWindowBaseName,
|
createWindowBaseName,
|
||||||
@@ -36,7 +35,7 @@ let mockCommandResponses: Record<
|
|||||||
let executedCommands: string[] = [];
|
let executedCommands: string[] = [];
|
||||||
|
|
||||||
function setupMockBun$() {
|
function setupMockBun$() {
|
||||||
const mockFn = mock((strings: TemplateStringsArray, ...values: any[]) => {
|
const mockFn = mock((_strings: TemplateStringsArray, ...values: any[]) => {
|
||||||
const parts = values[0] as string[];
|
const parts = values[0] as string[];
|
||||||
const commandSignature = parts.join(" ");
|
const commandSignature = parts.join(" ");
|
||||||
executedCommands.push(commandSignature);
|
executedCommands.push(commandSignature);
|
||||||
@@ -66,11 +65,11 @@ function restoreOriginalBun$() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("core utils", () => {
|
describe("core utils", () => {
|
||||||
let bunMock: ReturnType<typeof setupMockBun$>;
|
let _bunMock: ReturnType<typeof setupMockBun$>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(os, "homedir").mockReturnValue("/mock/home");
|
spyOn(os, "homedir").mockReturnValue("/mock/home");
|
||||||
bunMock = setupMockBun$();
|
_bunMock = setupMockBun$();
|
||||||
executedCommands = [];
|
executedCommands = [];
|
||||||
mockCommandResponses = {};
|
mockCommandResponses = {};
|
||||||
});
|
});
|
||||||
@@ -282,7 +281,7 @@ describe("core utils", () => {
|
|||||||
expect(result.stderr).toBe("");
|
expect(result.stderr).toBe("");
|
||||||
});
|
});
|
||||||
test("returns ok false for failed command", async () => {
|
test("returns ok false for failed command", async () => {
|
||||||
mockCommandResponses["false"] = {
|
mockCommandResponses.false = {
|
||||||
ok: false,
|
ok: false,
|
||||||
stdout: "",
|
stdout: "",
|
||||||
stderr: "error",
|
stderr: "error",
|
||||||
|
|||||||
Reference in New Issue
Block a user