mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 20:52:53 +00:00
chore(lint): enable stricter oxlint rules
This commit is contained in:
@@ -22,7 +22,7 @@ const { ensurePluginRegistryLoaded } = await import("../../plugin-registry.js");
|
||||
|
||||
const hasHooksMock = vi.fn((_hookName: string) => false);
|
||||
const runGatewayStopMock = vi.fn(
|
||||
async (eventValue: { reason?: string }, _ctx: Record<string, unknown>) => {},
|
||||
async (_eventValue: { reason?: string }, _ctx: Record<string, unknown>) => {},
|
||||
);
|
||||
const runGlobalGatewayStopSafelyMock = vi.fn(
|
||||
async (params: {
|
||||
|
||||
@@ -118,56 +118,59 @@ describe("registerPreActionHooks", () => {
|
||||
| null = null;
|
||||
|
||||
function buildProgram() {
|
||||
const program = new Command().name("openclaw");
|
||||
program
|
||||
const programLocal = new Command().name("openclaw");
|
||||
programLocal
|
||||
.command("agent")
|
||||
.requiredOption("-m, --message <text>")
|
||||
.option("--local")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
program
|
||||
programLocal
|
||||
.command("status")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
program
|
||||
programLocal
|
||||
.command("backup")
|
||||
.command("create")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
program.command("doctor").option("--lint").action(() => {});
|
||||
program.command("completion").action(() => {});
|
||||
program.command("secrets").action(() => {});
|
||||
program
|
||||
programLocal
|
||||
.command("doctor")
|
||||
.option("--lint")
|
||||
.action(() => {});
|
||||
programLocal.command("completion").action(() => {});
|
||||
programLocal.command("secrets").action(() => {});
|
||||
programLocal
|
||||
.command("agents")
|
||||
.command("list")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
program.command("configure").action(() => {});
|
||||
program.command("onboard").action(() => {});
|
||||
const channels = program.command("channels");
|
||||
programLocal.command("configure").action(() => {});
|
||||
programLocal.command("onboard").action(() => {});
|
||||
const channels = programLocal.command("channels");
|
||||
channels.command("add").action(() => {});
|
||||
channels
|
||||
.command("send")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
applyParentDefaultHelpAction(channels);
|
||||
program
|
||||
programLocal
|
||||
.command("plugins")
|
||||
.command("install")
|
||||
.argument("<spec>")
|
||||
.option("--marketplace <marketplace>")
|
||||
.action(() => {});
|
||||
program
|
||||
programLocal
|
||||
.command("update")
|
||||
.command("status")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
program
|
||||
programLocal
|
||||
.command("message")
|
||||
.command("send")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
const config = program.command("config");
|
||||
const config = programLocal.command("config");
|
||||
config.option("--section <section>");
|
||||
setCommandJsonMode(config.command("set"), "parse-only")
|
||||
.argument("<path>")
|
||||
@@ -179,8 +182,8 @@ describe("registerPreActionHooks", () => {
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
config.command("schema").action(() => {});
|
||||
registerPreActionHooks(program, "9.9.9-test");
|
||||
return program;
|
||||
registerPreActionHooks(programLocal, "9.9.9-test");
|
||||
return programLocal;
|
||||
}
|
||||
|
||||
function resolveActionCommand(parseArgv: string[]): Command {
|
||||
|
||||
@@ -44,8 +44,8 @@ function sessionDir(date: string, sessionId: string): string {
|
||||
return path.join(stateRootDir(), date, safeSegment(sessionId));
|
||||
}
|
||||
|
||||
function readDateFromSessionDir(sessionDir: string): string {
|
||||
const candidate = path.basename(path.dirname(sessionDir));
|
||||
function readDateFromSessionDir(sessionDirValue: string): string {
|
||||
const candidate = path.basename(path.dirname(sessionDirValue));
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(candidate)) {
|
||||
throw new Error(`invalid transcripts date directory: ${candidate}`);
|
||||
}
|
||||
@@ -97,17 +97,17 @@ function formatErrorMessage(err: unknown): string {
|
||||
}
|
||||
|
||||
async function readStoredSession(
|
||||
sessionDir: string,
|
||||
sessionDirLocal: string,
|
||||
options: { ignoreInvalid?: boolean } = {},
|
||||
): Promise<StoredTranscriptsSession | null> {
|
||||
const metadataPath = path.join(sessionDir, "metadata.json");
|
||||
const metadataPath = path.join(sessionDirLocal, "metadata.json");
|
||||
try {
|
||||
const session = await readJsonFile<TranscriptSessionDescriptor>(metadataPath);
|
||||
const summaryPath = path.join(sessionDir, "summary.md");
|
||||
const summaryPath = path.join(sessionDirLocal, "summary.md");
|
||||
return {
|
||||
session,
|
||||
sessionDir,
|
||||
date: readDateFromSessionDir(sessionDir),
|
||||
sessionDir: sessionDirLocal,
|
||||
date: readDateFromSessionDir(sessionDirLocal),
|
||||
summaryPath,
|
||||
hasSummary: await pathExists(summaryPath),
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { renderRootHelpText } from "./root-help.js";
|
||||
|
||||
const getPluginCliCommandDescriptorsMock = vi.fn(
|
||||
async (configForTest?: unknown, _env?: unknown, _loaderOptions?: unknown) => [
|
||||
async (_configForTest?: unknown, _env?: unknown, _loaderOptions?: unknown) => [
|
||||
{
|
||||
name: "matrix",
|
||||
description: "Matrix channel utilities",
|
||||
|
||||
Reference in New Issue
Block a user