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

@@ -34,7 +34,9 @@ function filterHookEntries(
function readHookPackageManifest(dir: string): HookPackageManifest | null {
const manifestPath = path.join(dir, "package.json");
if (!fs.existsSync(manifestPath)) return null;
if (!fs.existsSync(manifestPath)) {
return null;
}
try {
const raw = fs.readFileSync(manifestPath, "utf-8");
return JSON.parse(raw) as HookPackageManifest;
@@ -45,7 +47,9 @@ function readHookPackageManifest(dir: string): HookPackageManifest | null {
function resolvePackageHooks(manifest: HookPackageManifest): string[] {
const raw = manifest[MANIFEST_KEY]?.hooks;
if (!Array.isArray(raw)) return [];
if (!Array.isArray(raw)) {
return [];
}
return raw.map((entry) => (typeof entry === "string" ? entry.trim() : "")).filter(Boolean);
}
@@ -56,7 +60,9 @@ function loadHookFromDir(params: {
nameHint?: string;
}): Hook | null {
const hookMdPath = path.join(params.hookDir, "HOOK.md");
if (!fs.existsSync(hookMdPath)) return null;
if (!fs.existsSync(hookMdPath)) {
return null;
}
try {
const content = fs.readFileSync(hookMdPath, "utf-8");
@@ -101,16 +107,22 @@ function loadHookFromDir(params: {
function loadHooksFromDir(params: { dir: string; source: HookSource; pluginId?: string }): Hook[] {
const { dir, source, pluginId } = params;
if (!fs.existsSync(dir)) return [];
if (!fs.existsSync(dir)) {
return [];
}
const stat = fs.statSync(dir);
if (!stat.isDirectory()) return [];
if (!stat.isDirectory()) {
return [];
}
const hooks: Hook[] = [];
const entries = fs.readdirSync(dir, { withFileTypes: true });
for (const entry of entries) {
if (!entry.isDirectory()) continue;
if (!entry.isDirectory()) {
continue;
}
const hookDir = path.join(dir, entry.name);
const manifest = readHookPackageManifest(hookDir);
@@ -125,7 +137,9 @@ function loadHooksFromDir(params: { dir: string; source: HookSource; pluginId?:
pluginId,
nameHint: path.basename(resolvedHookDir),
});
if (hook) hooks.push(hook);
if (hook) {
hooks.push(hook);
}
}
continue;
}
@@ -136,7 +150,9 @@ function loadHooksFromDir(params: { dir: string; source: HookSource; pluginId?:
pluginId,
nameHint: entry.name,
});
if (hook) hooks.push(hook);
if (hook) {
hooks.push(hook);
}
}
return hooks;
@@ -214,10 +230,18 @@ function loadHookEntries(
const merged = new Map<string, Hook>();
// Precedence: extra < bundled < managed < workspace (workspace wins)
for (const hook of extraHooks) merged.set(hook.name, hook);
for (const hook of bundledHooks) merged.set(hook.name, hook);
for (const hook of managedHooks) merged.set(hook.name, hook);
for (const hook of workspaceHooks) merged.set(hook.name, hook);
for (const hook of extraHooks) {
merged.set(hook.name, hook);
}
for (const hook of bundledHooks) {
merged.set(hook.name, hook);
}
for (const hook of managedHooks) {
merged.set(hook.name, hook);
}
for (const hook of workspaceHooks) {
merged.set(hook.name, hook);
}
return Array.from(merged.values()).map((hook) => {
let frontmatter: ParsedHookFrontmatter = {};