mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 09:40:36 +00:00
chore: Lint extensions folder.
This commit is contained in:
@@ -29,7 +29,9 @@ function buildNameIndex<T>(items: T[], nameFn: (item: T) => string | undefined):
|
||||
const index = new Map<string, T[]>();
|
||||
for (const item of items) {
|
||||
const name = nameFn(item)?.trim().toLowerCase();
|
||||
if (!name) continue;
|
||||
if (!name) {
|
||||
continue;
|
||||
}
|
||||
const list = index.get(name) ?? [];
|
||||
list.push(item);
|
||||
index.set(name, list);
|
||||
@@ -46,7 +48,9 @@ function logVerbose(core: ZalouserCoreRuntime, runtime: RuntimeEnv, message: str
|
||||
}
|
||||
|
||||
function isSenderAllowed(senderId: string, allowFrom: string[]): boolean {
|
||||
if (allowFrom.includes("*")) return true;
|
||||
if (allowFrom.includes("*")) {
|
||||
return true;
|
||||
}
|
||||
const normalizedSenderId = senderId.toLowerCase();
|
||||
return allowFrom.some((entry) => {
|
||||
const normalized = entry.toLowerCase().replace(/^(zalouser|zlu):/i, "");
|
||||
@@ -56,7 +60,9 @@ function isSenderAllowed(senderId: string, allowFrom: string[]): boolean {
|
||||
|
||||
function normalizeGroupSlug(raw?: string | null): string {
|
||||
const trimmed = raw?.trim().toLowerCase() ?? "";
|
||||
if (!trimmed) return "";
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
}
|
||||
return trimmed
|
||||
.replace(/^#/, "")
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
@@ -70,7 +76,9 @@ function isGroupAllowed(params: {
|
||||
}): boolean {
|
||||
const groups = params.groups ?? {};
|
||||
const keys = Object.keys(groups);
|
||||
if (keys.length === 0) return false;
|
||||
if (keys.length === 0) {
|
||||
return false;
|
||||
}
|
||||
const candidates = [
|
||||
params.groupId,
|
||||
`group:${params.groupId}`,
|
||||
@@ -79,11 +87,15 @@ function isGroupAllowed(params: {
|
||||
].filter(Boolean);
|
||||
for (const candidate of candidates) {
|
||||
const entry = groups[candidate];
|
||||
if (!entry) continue;
|
||||
if (!entry) {
|
||||
continue;
|
||||
}
|
||||
return entry.allow !== false && entry.enabled !== false;
|
||||
}
|
||||
const wildcard = groups["*"];
|
||||
if (wildcard) return wildcard.allow !== false && wildcard.enabled !== false;
|
||||
if (wildcard) {
|
||||
return wildcard.allow !== false && wildcard.enabled !== false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,7 +116,9 @@ function startZcaListener(
|
||||
buffer = lines.pop() ?? "";
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) continue;
|
||||
if (!trimmed) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(trimmed) as ZcaMessage;
|
||||
onMessage(parsed);
|
||||
@@ -118,7 +132,9 @@ function startZcaListener(
|
||||
|
||||
proc.stderr?.on("data", (data: Buffer) => {
|
||||
const text = data.toString().trim();
|
||||
if (text) runtime.error(`[zalouser] zca stderr: ${text}`);
|
||||
if (text) {
|
||||
runtime.error(`[zalouser] zca stderr: ${text}`);
|
||||
}
|
||||
});
|
||||
|
||||
void promise.then((result) => {
|
||||
@@ -147,7 +163,9 @@ async function processMessage(
|
||||
statusSink?: (patch: { lastInboundAt?: number; lastOutboundAt?: number }) => void,
|
||||
): Promise<void> {
|
||||
const { threadId, content, timestamp, metadata } = message;
|
||||
if (!content?.trim()) return;
|
||||
if (!content?.trim()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isGroup = metadata?.isGroup ?? false;
|
||||
const senderId = metadata?.fromId ?? threadId;
|
||||
@@ -476,7 +494,9 @@ export async function monitorZalouserProvider(
|
||||
for (const entry of groupKeys) {
|
||||
const cleaned = normalizeZalouserEntry(entry);
|
||||
if (/^\d+$/.test(cleaned)) {
|
||||
if (!nextGroups[cleaned]) nextGroups[cleaned] = groupsConfig[entry];
|
||||
if (!nextGroups[cleaned]) {
|
||||
nextGroups[cleaned] = groupsConfig[entry];
|
||||
}
|
||||
mapping.push(`${entry}→${cleaned}`);
|
||||
continue;
|
||||
}
|
||||
@@ -484,7 +504,9 @@ export async function monitorZalouserProvider(
|
||||
const match = matches[0];
|
||||
const id = match?.groupId ? String(match.groupId) : undefined;
|
||||
if (id) {
|
||||
if (!nextGroups[id]) nextGroups[id] = groupsConfig[entry];
|
||||
if (!nextGroups[id]) {
|
||||
nextGroups[id] = groupsConfig[entry];
|
||||
}
|
||||
mapping.push(`${entry}→${id}`);
|
||||
} else {
|
||||
unresolved.push(entry);
|
||||
|
||||
Reference in New Issue
Block a user