chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -12,21 +12,33 @@ export function hasControlCommand(
cfg?: OpenClawConfig,
options?: CommandNormalizeOptions,
): boolean {
if (!text) return false;
if (!text) {
return false;
}
const trimmed = text.trim();
if (!trimmed) return false;
if (!trimmed) {
return false;
}
const normalizedBody = normalizeCommandBody(trimmed, options);
if (!normalizedBody) return false;
if (!normalizedBody) {
return false;
}
const lowered = normalizedBody.toLowerCase();
const commands = cfg ? listChatCommandsForConfig(cfg) : listChatCommands();
for (const command of commands) {
for (const alias of command.textAliases) {
const normalized = alias.trim().toLowerCase();
if (!normalized) continue;
if (lowered === normalized) return true;
if (!normalized) {
continue;
}
if (lowered === normalized) {
return true;
}
if (command.acceptsArgs && lowered.startsWith(normalized)) {
const nextChar = normalizedBody.charAt(normalized.length);
if (nextChar && /\s/.test(nextChar)) return true;
if (nextChar && /\s/.test(nextChar)) {
return true;
}
}
}
}
@@ -38,10 +50,16 @@ export function isControlCommandMessage(
cfg?: OpenClawConfig,
options?: CommandNormalizeOptions,
): boolean {
if (!text) return false;
if (!text) {
return false;
}
const trimmed = text.trim();
if (!trimmed) return false;
if (hasControlCommand(trimmed, cfg, options)) return true;
if (!trimmed) {
return false;
}
if (hasControlCommand(trimmed, cfg, options)) {
return true;
}
const normalized = normalizeCommandBody(trimmed, options).trim().toLowerCase();
return isAbortTrigger(normalized);
}
@@ -55,7 +73,9 @@ export function isControlCommandMessage(
*/
export function hasInlineCommandTokens(text?: string): boolean {
const body = text ?? "";
if (!body.trim()) return false;
if (!body.trim()) {
return false;
}
return /(?:^|\s)[/!][a-z]/i.test(body);
}