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

@@ -11,10 +11,7 @@ describe("retryAsync", () => {
});
it("retries then succeeds", async () => {
const fn = vi
.fn()
.mockRejectedValueOnce(new Error("fail1"))
.mockResolvedValueOnce("ok");
const fn = vi.fn().mockRejectedValueOnce(new Error("fail1")).mockResolvedValueOnce("ok");
const result = await retryAsync(fn, 3, 1);
expect(result).toBe("ok");
expect(fn).toHaveBeenCalledTimes(2);
@@ -28,17 +25,12 @@ describe("retryAsync", () => {
it("stops when shouldRetry returns false", async () => {
const fn = vi.fn().mockRejectedValue(new Error("boom"));
await expect(
retryAsync(fn, { attempts: 3, shouldRetry: () => false }),
).rejects.toThrow("boom");
await expect(retryAsync(fn, { attempts: 3, shouldRetry: () => false })).rejects.toThrow("boom");
expect(fn).toHaveBeenCalledTimes(1);
});
it("calls onRetry before retrying", async () => {
const fn = vi
.fn()
.mockRejectedValueOnce(new Error("boom"))
.mockResolvedValueOnce("ok");
const fn = vi.fn().mockRejectedValueOnce(new Error("boom")).mockResolvedValueOnce("ok");
const onRetry = vi.fn();
const res = await retryAsync(fn, {
attempts: 2,
@@ -47,25 +39,20 @@ describe("retryAsync", () => {
onRetry,
});
expect(res).toBe("ok");
expect(onRetry).toHaveBeenCalledWith(
expect.objectContaining({ attempt: 1, maxAttempts: 2 }),
);
expect(onRetry).toHaveBeenCalledWith(expect.objectContaining({ attempt: 1, maxAttempts: 2 }));
});
it("clamps attempts to at least 1", async () => {
const fn = vi.fn().mockRejectedValue(new Error("boom"));
await expect(
retryAsync(fn, { attempts: 0, minDelayMs: 0, maxDelayMs: 0 }),
).rejects.toThrow("boom");
await expect(retryAsync(fn, { attempts: 0, minDelayMs: 0, maxDelayMs: 0 })).rejects.toThrow(
"boom",
);
expect(fn).toHaveBeenCalledTimes(1);
});
it("uses retryAfterMs when provided", async () => {
vi.useFakeTimers();
const fn = vi
.fn()
.mockRejectedValueOnce(new Error("boom"))
.mockResolvedValueOnce("ok");
const fn = vi.fn().mockRejectedValueOnce(new Error("boom")).mockResolvedValueOnce("ok");
const delays: number[] = [];
const promise = retryAsync(fn, {
attempts: 2,
@@ -83,10 +70,7 @@ describe("retryAsync", () => {
it("clamps retryAfterMs to maxDelayMs", async () => {
vi.useFakeTimers();
const fn = vi
.fn()
.mockRejectedValueOnce(new Error("boom"))
.mockResolvedValueOnce("ok");
const fn = vi.fn().mockRejectedValueOnce(new Error("boom")).mockResolvedValueOnce("ok");
const delays: number[] = [];
const promise = retryAsync(fn, {
attempts: 2,