mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
chore: Enable more lint rules, disable some that trigger a lot. Will clean up later.
This commit is contained in:
@@ -66,7 +66,7 @@ export function hasAnyWhatsAppAuth(cfg: OpenClawConfig): boolean {
|
||||
export function listWhatsAppAccountIds(cfg: OpenClawConfig): string[] {
|
||||
const ids = listConfiguredAccountIds(cfg);
|
||||
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
|
||||
return ids.sort((a, b) => a.localeCompare(b));
|
||||
return ids.toSorted((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
export function resolveDefaultWhatsAppAccountId(cfg: OpenClawConfig): string {
|
||||
|
||||
@@ -24,7 +24,7 @@ export function createEchoTracker(params: {
|
||||
|
||||
const trim = () => {
|
||||
while (recentlySent.size > maxItems) {
|
||||
const firstKey = recentlySent.values().next().value as string | undefined;
|
||||
const firstKey = recentlySent.values().next().value;
|
||||
if (!firstKey) break;
|
||||
recentlySent.delete(firstKey);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ export function resolveGroupActivationFor(params: {
|
||||
const store = loadSessionStore(storePath);
|
||||
const entry = store[params.sessionKey];
|
||||
const requireMention = resolveGroupRequireMentionFor(params.cfg, params.conversationId);
|
||||
const defaultActivation = requireMention === false ? "always" : "mention";
|
||||
const defaultActivation = !requireMention ? "always" : "mention";
|
||||
return normalizeGroupActivation(entry?.groupActivation) ?? defaultActivation;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import { jidToE164 } from "../../utils.js";
|
||||
import { parseVcard } from "../vcard.js";
|
||||
|
||||
function unwrapMessage(message: proto.IMessage | undefined): proto.IMessage | undefined {
|
||||
const normalized = normalizeMessageContent(message as proto.IMessage | undefined);
|
||||
return normalized as proto.IMessage | undefined;
|
||||
const normalized = normalizeMessageContent(message);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function extractContextInfo(message: proto.IMessage | undefined): proto.IContextInfo | undefined {
|
||||
@@ -244,9 +244,7 @@ export function describeReplyContext(rawMessage: proto.IMessage | undefined): {
|
||||
const message = unwrapMessage(rawMessage);
|
||||
if (!message) return null;
|
||||
const contextInfo = extractContextInfo(message);
|
||||
const quoted = normalizeMessageContent(
|
||||
contextInfo?.quotedMessage as proto.IMessage | undefined,
|
||||
) as proto.IMessage | undefined;
|
||||
const quoted = normalizeMessageContent(contextInfo?.quotedMessage as proto.IMessage | undefined);
|
||||
if (!quoted) return null;
|
||||
const location = extractLocationData(quoted);
|
||||
const locationText = location ? formatLocationText(location) : undefined;
|
||||
|
||||
@@ -4,8 +4,8 @@ import { logVerbose } from "../../globals.js";
|
||||
import type { createWaSocket } from "../session.js";
|
||||
|
||||
function unwrapMessage(message: proto.IMessage | undefined): proto.IMessage | undefined {
|
||||
const normalized = normalizeMessageContent(message as proto.IMessage | undefined);
|
||||
return normalized as proto.IMessage | undefined;
|
||||
const normalized = normalizeMessageContent(message);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export async function downloadInboundMedia(
|
||||
@@ -31,7 +31,7 @@ export async function downloadInboundMedia(
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
const buffer = (await downloadMediaMessage(
|
||||
const buffer = await downloadMediaMessage(
|
||||
msg as WAMessage,
|
||||
"buffer",
|
||||
{},
|
||||
@@ -39,7 +39,7 @@ export async function downloadInboundMedia(
|
||||
reuploadRequest: sock.updateMediaMessage,
|
||||
logger: sock.logger,
|
||||
},
|
||||
)) as Buffer;
|
||||
);
|
||||
return { buffer, mimetype };
|
||||
} catch (err) {
|
||||
logVerbose(`downloadMediaMessage failed: ${String(err)}`);
|
||||
|
||||
@@ -60,11 +60,11 @@ export async function loginWeb(
|
||||
`WhatsApp reported the session is logged out. Cleared cached web session; please rerun ${formatCliCommand("openclaw channels login")} and scan the QR again.`,
|
||||
),
|
||||
);
|
||||
throw new Error("Session logged out; cache cleared. Re-run login.");
|
||||
throw new Error("Session logged out; cache cleared. Re-run login.", { cause: err });
|
||||
}
|
||||
const formatted = formatError(err);
|
||||
console.error(danger(`WhatsApp Web connection ended before fully opening. ${formatted}`));
|
||||
throw new Error(formatted);
|
||||
throw new Error(formatted, { cause: err });
|
||||
} finally {
|
||||
// Let Baileys flush any final events before closing the socket.
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -250,7 +250,7 @@ export async function optimizeImageToJpeg(
|
||||
try {
|
||||
source = await convertHeicToJpeg(buffer);
|
||||
} catch (err) {
|
||||
throw new Error(`HEIC image conversion failed: ${String(err)}`);
|
||||
throw new Error(`HEIC image conversion failed: ${String(err)}`, { cause: err });
|
||||
}
|
||||
}
|
||||
const sides = [2048, 1536, 1280, 1024, 800];
|
||||
|
||||
@@ -12,8 +12,8 @@ type QRCodeConstructor = new (
|
||||
isDark: (row: number, col: number) => boolean;
|
||||
};
|
||||
|
||||
const QRCode = QRCodeModule as unknown as QRCodeConstructor;
|
||||
const QRErrorCorrectLevel = QRErrorCorrectLevelModule as Record<string, unknown>;
|
||||
const QRCode = QRCodeModule as QRCodeConstructor;
|
||||
const QRErrorCorrectLevel = QRErrorCorrectLevelModule;
|
||||
|
||||
function createQrMatrix(input: string) {
|
||||
const qr = new QRCode(-1, QRErrorCorrectLevel.L);
|
||||
|
||||
@@ -193,7 +193,7 @@ export function getStatusCode(err: unknown) {
|
||||
|
||||
function safeStringify(value: unknown, limit = 800): string {
|
||||
try {
|
||||
const seen = new WeakSet<object>();
|
||||
const seen = new WeakSet();
|
||||
const raw = JSON.stringify(
|
||||
value,
|
||||
(_key, v) => {
|
||||
@@ -236,7 +236,7 @@ function extractBoomDetails(err: unknown): {
|
||||
typeof (output as { statusCode?: unknown }).statusCode === "number"
|
||||
? ((output as { statusCode?: unknown }).statusCode as number)
|
||||
: typeof payload?.statusCode === "number"
|
||||
? (payload.statusCode as number)
|
||||
? payload.statusCode
|
||||
: undefined;
|
||||
const error = typeof payload?.error === "string" ? payload.error : undefined;
|
||||
const message = typeof payload?.message === "string" ? payload.message : undefined;
|
||||
|
||||
Reference in New Issue
Block a user