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

@@ -25,17 +25,25 @@ const matchLevelDirective = (
): { start: number; end: number; rawLevel?: string } | null => {
const namePattern = names.map(escapeRegExp).join("|");
const match = body.match(new RegExp(`(?:^|\\s)\\/(?:${namePattern})(?=$|\\s|:)`, "i"));
if (!match || match.index === undefined) return null;
if (!match || match.index === undefined) {
return null;
}
const start = match.index;
let end = match.index + match[0].length;
let i = end;
while (i < body.length && /\s/.test(body[i])) i += 1;
while (i < body.length && /\s/.test(body[i])) {
i += 1;
}
if (body[i] === ":") {
i += 1;
while (i < body.length && /\s/.test(body[i])) i += 1;
while (i < body.length && /\s/.test(body[i])) {
i += 1;
}
}
const argStart = i;
while (i < body.length && /[A-Za-z-]/.test(body[i])) i += 1;
while (i < body.length && /[A-Za-z-]/.test(body[i])) {
i += 1;
}
const rawLevel = i > argStart ? body.slice(argStart, i) : undefined;
end = i;
return { start, end, rawLevel };
@@ -87,7 +95,9 @@ export function extractThinkDirective(body?: string): {
rawLevel?: string;
hasDirective: boolean;
} {
if (!body) return { cleaned: "", hasDirective: false };
if (!body) {
return { cleaned: "", hasDirective: false };
}
const extracted = extractLevelDirective(body, ["thinking", "think", "t"], normalizeThinkLevel);
return {
cleaned: extracted.cleaned,
@@ -103,7 +113,9 @@ export function extractVerboseDirective(body?: string): {
rawLevel?: string;
hasDirective: boolean;
} {
if (!body) return { cleaned: "", hasDirective: false };
if (!body) {
return { cleaned: "", hasDirective: false };
}
const extracted = extractLevelDirective(body, ["verbose", "v"], normalizeVerboseLevel);
return {
cleaned: extracted.cleaned,
@@ -119,7 +131,9 @@ export function extractNoticeDirective(body?: string): {
rawLevel?: string;
hasDirective: boolean;
} {
if (!body) return { cleaned: "", hasDirective: false };
if (!body) {
return { cleaned: "", hasDirective: false };
}
const extracted = extractLevelDirective(body, ["notice", "notices"], normalizeNoticeLevel);
return {
cleaned: extracted.cleaned,
@@ -135,7 +149,9 @@ export function extractElevatedDirective(body?: string): {
rawLevel?: string;
hasDirective: boolean;
} {
if (!body) return { cleaned: "", hasDirective: false };
if (!body) {
return { cleaned: "", hasDirective: false };
}
const extracted = extractLevelDirective(body, ["elevated", "elev"], normalizeElevatedLevel);
return {
cleaned: extracted.cleaned,
@@ -151,7 +167,9 @@ export function extractReasoningDirective(body?: string): {
rawLevel?: string;
hasDirective: boolean;
} {
if (!body) return { cleaned: "", hasDirective: false };
if (!body) {
return { cleaned: "", hasDirective: false };
}
const extracted = extractLevelDirective(body, ["reasoning", "reason"], normalizeReasoningLevel);
return {
cleaned: extracted.cleaned,
@@ -165,7 +183,9 @@ export function extractStatusDirective(body?: string): {
cleaned: string;
hasDirective: boolean;
} {
if (!body) return { cleaned: "", hasDirective: false };
if (!body) {
return { cleaned: "", hasDirective: false };
}
return extractSimpleDirective(body, ["status"]);
}