chore: Fix lint.

This commit is contained in:
cpojer
2026-02-09 09:55:48 +09:00
parent 0497bb0544
commit 6614c3f932
5 changed files with 22 additions and 8 deletions

View File

@@ -6,10 +6,17 @@ import {
refreshChutesTokens,
} from "./chutes-oauth.js";
const urlToString = (url: Request | URL | string): string => {
if (typeof url === "string") {
return url;
}
return "url" in url ? url.url : String(url);
};
describe("chutes-oauth", () => {
it("exchanges code for tokens and stores username as email", async () => {
const fetchFn: typeof fetch = async (input, init) => {
const url = String(input);
const url = urlToString(input);
if (url === CHUTES_TOKEN_ENDPOINT) {
expect(init?.method).toBe("POST");
expect(
@@ -59,7 +66,7 @@ describe("chutes-oauth", () => {
it("refreshes tokens using stored client id and falls back to old refresh token", async () => {
const fetchFn: typeof fetch = async (input, init) => {
const url = String(input);
const url = urlToString(input);
if (url !== CHUTES_TOKEN_ENDPOINT) {
return new Response("not found", { status: 404 });
}

View File

@@ -37,7 +37,7 @@ function installFailingFetchCapture() {
if (rawBody instanceof ArrayBuffer) {
return Buffer.from(new Uint8Array(rawBody)).toString("utf8");
}
return String(rawBody);
return null;
})();
lastBody = bodyText ? (JSON.parse(bodyText) as unknown) : undefined;
throw new Error("intentional fetch abort (test)");

View File

@@ -103,7 +103,7 @@ describe("acquireSessionWriteLock", () => {
});
it("cleans up locks on SIGINT without removing other handlers", async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-lock-"));
const originalKill = process.kill.bind(process) as typeof process.kill;
const originalKill = process.kill.bind(process);
const killCalls: Array<NodeJS.Signals | undefined> = [];
let otherHandlerCalled = false;

View File

@@ -19,13 +19,20 @@ async function getFreePort(): Promise<number> {
});
}
const urlToString = (url: Request | URL | string): string => {
if (typeof url === "string") {
return url;
}
return "url" in url ? url.url : String(url);
};
describe("loginChutes", () => {
it("captures local redirect and exchanges code for tokens", async () => {
const port = await getFreePort();
const redirectUri = `http://127.0.0.1:${port}/oauth-callback`;
const fetchFn: typeof fetch = async (input, init) => {
const url = String(input);
const url = urlToString(input);
if (url === CHUTES_TOKEN_ENDPOINT) {
return new Response(
JSON.stringify({
@@ -68,7 +75,7 @@ describe("loginChutes", () => {
it("supports manual flow with pasted code", async () => {
const fetchFn: typeof fetch = async (input) => {
const url = String(input);
const url = urlToString(input);
if (url === CHUTES_TOKEN_ENDPOINT) {
return new Response(
JSON.stringify({
@@ -107,7 +114,7 @@ describe("loginChutes", () => {
it("does not reuse code_verifier as state", async () => {
const fetchFn: typeof fetch = async (input) => {
const url = String(input);
const url = urlToString(input);
if (url === CHUTES_TOKEN_ENDPOINT) {
return new Response(
JSON.stringify({

View File

@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { installProcessWarningFilter, shouldIgnoreWarning } from "./warning-filter.js";
const warningFilterKey = Symbol.for("openclaw.warning-filter");
const baseEmitWarning = process.emitWarning.bind(process) as typeof process.emitWarning;
const baseEmitWarning = process.emitWarning.bind(process);
function resetWarningFilterInstallState(): void {
const globalState = globalThis as typeof globalThis & {