diff --git a/src/tools/lsp/directory-diagnostics.test.ts b/src/tools/lsp/directory-diagnostics.test.ts index b46875a70..1c8f89133 100644 --- a/src/tools/lsp/directory-diagnostics.test.ts +++ b/src/tools/lsp/directory-diagnostics.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from "bun:test" import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "fs" +import { tmpdir } from "os" import { join } from "path" -import os from "os" import * as configModule from "./config" import { lspManager } from "./lsp-server" @@ -40,7 +40,7 @@ describe("directory diagnostics", () => { priority: 1, }, }) - spyOn(lspManager, "getClient").mockImplementation(getClientMock) + spyOn(lspManager, "getClient").mockImplementation(getClientMock as never) spyOn(lspManager, "releaseClient").mockImplementation(releaseClientMock) }) @@ -50,7 +50,7 @@ describe("directory diagnostics", () => { describe("isDirectoryPath", () => { it("returns true for existing directory", () => { - const tmp = mkdtempSync(join(os.tmpdir(), "omo-isdir-")) + const tmp = mkdtempSync(join(tmpdir(), "omo-isdir-")) try { expect(isDirectoryPath(tmp)).toBe(true) } finally { @@ -59,7 +59,7 @@ describe("directory diagnostics", () => { }) it("returns false for existing file", () => { - const tmp = mkdtempSync(join(os.tmpdir(), "omo-isdir-file-")) + const tmp = mkdtempSync(join(tmpdir(), "omo-isdir-file-")) try { const file = join(tmp, "test.txt") writeFileSync(file, "content") @@ -70,14 +70,14 @@ describe("directory diagnostics", () => { }) it("returns false for non-existent path", () => { - const nonExistent = join(os.tmpdir(), "omo-nonexistent-" + Date.now()) + const nonExistent = join(tmpdir(), "omo-nonexistent-" + Date.now()) expect(isDirectoryPath(nonExistent)).toBe(false) }) }) describe("aggregateDiagnosticsForDirectory", () => { it("throws error when extension does not start with dot", async () => { - const tmp = mkdtempSync(join(os.tmpdir(), "omo-aggr-ext-")) + const tmp = mkdtempSync(join(tmpdir(), "omo-aggr-ext-")) try { await expect(aggregateDiagnosticsForDirectory(tmp, "ts")).rejects.toThrow( 'Extension must start with a dot (e.g., ".ts", not "ts")' @@ -88,14 +88,14 @@ describe("directory diagnostics", () => { }) it("throws error when directory does not exist", async () => { - const nonExistent = join(os.tmpdir(), "omo-nonexistent-dir-" + Date.now()) + const nonExistent = join(tmpdir(), "omo-nonexistent-dir-" + Date.now()) await expect(aggregateDiagnosticsForDirectory(nonExistent, ".ts")).rejects.toThrow( "Directory does not exist" ) }) it("#given diagnostics from multiple files #when aggregating directory diagnostics #then each entry includes the source file path", async () => { - const tmp = mkdtempSync(join(os.tmpdir(), "omo-aggr-files-")) + const tmp = mkdtempSync(join(tmpdir(), "omo-aggr-files-")) try { const firstFile = join(tmp, "first.ts") const secondFile = join(tmp, "second.ts") diff --git a/src/tools/lsp/infer-extension.test.ts b/src/tools/lsp/infer-extension.test.ts index 0453e7e69..6aea85838 100644 --- a/src/tools/lsp/infer-extension.test.ts +++ b/src/tools/lsp/infer-extension.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it } from "bun:test" import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "fs" +import { tmpdir } from "os" import { join } from "path" -import os from "os" import { inferExtensionFromDirectory } from "./infer-extension" @@ -9,7 +9,7 @@ describe("inferExtensionFromDirectory", () => { let tmpDir: string beforeEach(() => { - tmpDir = mkdtempSync(join(os.tmpdir(), "omo-infer-ext-")) + tmpDir = mkdtempSync(join(tmpdir(), "omo-infer-ext-")) }) afterEach(() => { diff --git a/src/tools/lsp/utils.test.ts b/src/tools/lsp/utils.test.ts index 50788f9fe..a323bd872 100644 --- a/src/tools/lsp/utils.test.ts +++ b/src/tools/lsp/utils.test.ts @@ -1,14 +1,14 @@ import { describe, expect, it } from "bun:test" import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "fs" +import { tmpdir } from "os" import { join } from "path" -import os from "os" import { findWorkspaceRoot } from "./lsp-client-wrapper" describe("lsp utils", () => { describe("findWorkspaceRoot", () => { it("returns an existing directory even when the file path points to a non-existent nested path", () => { - const tmp = mkdtempSync(join(os.tmpdir(), "omo-lsp-root-")) + const tmp = mkdtempSync(join(tmpdir(), "omo-lsp-root-")) try { // Add a marker so the function can discover the workspace root. writeFileSync(join(tmp, "package.json"), "{}") @@ -23,7 +23,7 @@ describe("lsp utils", () => { }) it("prefers the nearest marker directory when markers exist above the file", () => { - const tmp = mkdtempSync(join(os.tmpdir(), "omo-lsp-marker-")) + const tmp = mkdtempSync(join(tmpdir(), "omo-lsp-marker-")) try { const repo = join(tmp, "repo") const src = join(repo, "src")