chore: migrate to oxlint and oxfmt

Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-14 14:31:43 +00:00
parent 912ebffc63
commit c379191f80
1480 changed files with 28608 additions and 43547 deletions

View File

@@ -38,9 +38,7 @@ describe("withWhatsAppPrefix", () => {
describe("ensureDir", () => {
it("creates nested directory", async () => {
const tmp = await fs.promises.mkdtemp(
path.join(os.tmpdir(), "clawdbot-test-"),
);
const tmp = await fs.promises.mkdtemp(path.join(os.tmpdir(), "clawdbot-test-"));
const target = path.join(tmp, "nested", "dir");
await ensureDir(target);
expect(fs.existsSync(target)).toBe(true);
@@ -66,31 +64,19 @@ describe("assertWebChannel", () => {
describe("normalizeE164 & toWhatsappJid", () => {
it("strips formatting and prefixes", () => {
expect(normalizeE164("whatsapp:(555) 123-4567")).toBe("+5551234567");
expect(toWhatsappJid("whatsapp:+555 123 4567")).toBe(
"5551234567@s.whatsapp.net",
);
expect(toWhatsappJid("whatsapp:+555 123 4567")).toBe("5551234567@s.whatsapp.net");
});
it("preserves existing JIDs", () => {
expect(toWhatsappJid("123456789-987654321@g.us")).toBe(
"123456789-987654321@g.us",
);
expect(toWhatsappJid("whatsapp:123456789-987654321@g.us")).toBe(
"123456789-987654321@g.us",
);
expect(toWhatsappJid("1555123@s.whatsapp.net")).toBe(
"1555123@s.whatsapp.net",
);
expect(toWhatsappJid("123456789-987654321@g.us")).toBe("123456789-987654321@g.us");
expect(toWhatsappJid("whatsapp:123456789-987654321@g.us")).toBe("123456789-987654321@g.us");
expect(toWhatsappJid("1555123@s.whatsapp.net")).toBe("1555123@s.whatsapp.net");
});
});
describe("jidToE164", () => {
it("maps @lid using reverse mapping file", () => {
const mappingPath = path.join(
CONFIG_DIR,
"credentials",
"lid-mapping-123_reverse.json",
);
const mappingPath = path.join(CONFIG_DIR, "credentials", "lid-mapping-123_reverse.json");
const original = fs.readFileSync;
const spy = vi
.spyOn(fs, "readFileSync")
@@ -128,9 +114,7 @@ describe("jidToE164", () => {
const second = fs.mkdtempSync(path.join(os.tmpdir(), "clawdbot-lid-b-"));
const mappingPath = path.join(second, "lid-mapping-321_reverse.json");
fs.writeFileSync(mappingPath, JSON.stringify("123321"));
expect(jidToE164("321@lid", { lidMappingDirs: [first, second] })).toBe(
"+123321",
);
expect(jidToE164("321@lid", { lidMappingDirs: [first, second] })).toBe("+123321");
fs.rmSync(first, { recursive: true, force: true });
fs.rmSync(second, { recursive: true, force: true });
});
@@ -141,9 +125,7 @@ describe("resolveJidToE164", () => {
const lidLookup = {
getPNForLID: vi.fn().mockResolvedValue("777:0@s.whatsapp.net"),
};
await expect(resolveJidToE164("777@lid", { lidLookup })).resolves.toBe(
"+777",
);
await expect(resolveJidToE164("777@lid", { lidLookup })).resolves.toBe("+777");
expect(lidLookup.getPNForLID).toHaveBeenCalledWith("777@lid");
});
@@ -151,9 +133,7 @@ describe("resolveJidToE164", () => {
const lidLookup = {
getPNForLID: vi.fn().mockResolvedValue("888:0@s.whatsapp.net"),
};
await expect(
resolveJidToE164("888@s.whatsapp.net", { lidLookup }),
).resolves.toBe("+888");
await expect(resolveJidToE164("888@s.whatsapp.net", { lidLookup })).resolves.toBe("+888");
expect(lidLookup.getPNForLID).not.toHaveBeenCalled();
});
});
@@ -164,9 +144,7 @@ describe("resolveUserPath", () => {
});
it("expands ~/ to home dir", () => {
expect(resolveUserPath("~/clawd")).toBe(
path.resolve(os.homedir(), "clawd"),
);
expect(resolveUserPath("~/clawd")).toBe(path.resolve(os.homedir(), "clawd"));
});
it("resolves relative paths", () => {