Skip to content

Commit dd218b9

Browse files
committed
chore(scripts): satisfy oxlint curly + consistent-function-scoping rules
Bare-return and single-line `if` statements tripped the `curly` rule, and `isFullSha` was declared inside `writeMetaFiles` even though it didn't capture any parent-scope bindings. Hoist the helper to module scope and add braces to every single-statement `if`.
1 parent 93ebe40 commit dd218b9

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

.github/scripts/upgrade-deps.mjs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ import path from 'node:path';
44
const ROOT = process.cwd();
55
const META_DIR = process.env.UPGRADE_DEPS_META_DIR;
66

7+
const isFullSha = (s) => /^[0-9a-f]{40}$/.test(s);
8+
79
/** @type {Map<string, { old: string | null, new: string, tag?: string }>} */
810
const changes = new Map();
911

1012
function recordChange(name, oldValue, newValue, tag) {
1113
const entry = { old: oldValue ?? null, new: newValue };
12-
if (tag) entry.tag = tag;
14+
if (tag) {
15+
entry.tag = tag;
16+
}
1317
changes.set(name, entry);
1418
if (oldValue !== newValue) {
1519
console.log(` ${name}: ${oldValue ?? '(unset)'} -> ${newValue}`);
@@ -181,7 +185,9 @@ async function updateCorePackage(devtoolsVersion) {
181185

182186
// ============ Write metadata files for PR description ============
183187
function writeMetaFiles() {
184-
if (!META_DIR) return;
188+
if (!META_DIR) {
189+
return;
190+
}
185191

186192
fs.mkdirSync(META_DIR, { recursive: true });
187193

@@ -194,15 +200,22 @@ function writeMetaFiles() {
194200
const changed = [...changes.entries()].filter(([, v]) => v.old !== v.new);
195201
const unchanged = [...changes.entries()].filter(([, v]) => v.old === v.new);
196202

197-
const isFullSha = (s) => /^[0-9a-f]{40}$/.test(s);
198203
const formatVersion = (v) => {
199-
if (v.tag) return `${v.tag} (${v.new.slice(0, 7)})`;
200-
if (isFullSha(v.new)) return v.new.slice(0, 7);
204+
if (v.tag) {
205+
return `${v.tag} (${v.new.slice(0, 7)})`;
206+
}
207+
if (isFullSha(v.new)) {
208+
return v.new.slice(0, 7);
209+
}
201210
return v.new;
202211
};
203212
const formatOld = (v) => {
204-
if (!v.old) return '(unset)';
205-
if (isFullSha(v.old)) return v.old.slice(0, 7);
213+
if (!v.old) {
214+
return '(unset)';
215+
}
216+
if (isFullSha(v.old)) {
217+
return v.old.slice(0, 7);
218+
}
206219
return v.old;
207220
};
208221

0 commit comments

Comments
 (0)