Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit 26d9bff

Browse files
committed
Cosmetic
1 parent 6b06a07 commit 26d9bff

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/pr-info.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ async function getPackageInfosEtc(
333333
return { pkgInfo: result, popularityLevel: downloadsToPopularityLevel(maxDownloads) };
334334
}
335335

336-
async function categorizeFile(path: string, contents: (ref: string) => Promise<string | undefined>): Promise<[string|null, FileInfo]> {
336+
async function categorizeFile(path: string, getContents: (ref: string) => Promise<string | undefined>): Promise<[string|null, FileInfo]> {
337337
// https://regex101.com/r/eFvtrz/1
338338
const match = /^types\/(.*?)\/.*?[^\/](?:\.(d\.ts|tsx?|md))?$/.exec(path);
339339
if (!match) return [null, { path, kind: "infrastructure" }];
@@ -344,26 +344,26 @@ async function categorizeFile(path: string, contents: (ref: string) => Promise<s
344344
case "ts": case "tsx": return [pkg, { path, kind: "test" }];
345345
case "md": return [pkg, { path, kind: "markdown" }];
346346
default: {
347-
const suspect = await configSuspicious(path, contents);
347+
const suspect = await configSuspicious(path, getContents);
348348
return [pkg, { path, kind: suspect ? "package-meta" : "package-meta-ok", ...suspect }];
349349
}
350350
}
351351
}
352352

353353
interface ConfigSuspicious {
354354
(path: string, getContents: (ref: string) => Promise<string | undefined>): Promise<{ suspect: string, sugestion?: Suggestion } | undefined>;
355-
[basename: string]: (text: string, getContents: (ref: string) => Promise<string | undefined>) => Promise<{ suspect: string, suggestion?: Suggestion } | undefined>;
355+
[basename: string]: (newText: string, getContents: (ref: string) => Promise<string | undefined>) => Promise<{ suspect: string, suggestion?: Suggestion } | undefined>;
356356
}
357357
const configSuspicious = <ConfigSuspicious>(async (path, getContents) => {
358358
const basename = path.replace(/.*\//, "");
359359
const checker = configSuspicious[basename];
360360
if (!checker) return { suspect: `edited` };
361-
const text = await getContents("head");
361+
const newText = await getContents("head");
362362
// Removing tslint.json, tsconfig.json, package.json and
363363
// OTHER_FILES.txt is checked by the CI. Specifics are in my commit
364364
// message.
365-
if (text === undefined) return undefined;
366-
return checker(text, getContents);
365+
if (newText === undefined) return undefined;
366+
return checker(newText, getContents);
367367
});
368368
configSuspicious["OTHER_FILES.txt"] = makeChecker(
369369
[],
@@ -411,12 +411,12 @@ configSuspicious["tsconfig.json"] = makeChecker(
411411
// to it, ignoring some keys. The ignored properties are in most cases checked
412412
// elsewhere (dtslint), and in some cases they are irrelevant.
413413
function makeChecker(expectedForm: any, expectedFormUrl: string, options?: { parse: (text: string) => unknown } | { ignore: (data: any) => void }) {
414-
return async (contents: string, getContents: (ref: string) => Promise<string | undefined>) => {
414+
return async (newText: string, getContents: (ref: string) => Promise<string | undefined>) => {
415415
let suggestion: any;
416416
if (options && "parse" in options) {
417-
suggestion = options.parse(contents);
417+
suggestion = options.parse(newText);
418418
} else {
419-
try { suggestion = JSON.parse(contents); } catch (e) { if (e instanceof SyntaxError) return { suspect: `couldn't parse json: ${e.message}` }; }
419+
try { suggestion = JSON.parse(newText); } catch (e) { if (e instanceof SyntaxError) return { suspect: `couldn't parse json: ${e.message}` }; }
420420
}
421421
const newData = jsonDiff.deepClone(suggestion);
422422
if (options && "ignore" in options) options.ignore(newData);
@@ -465,7 +465,7 @@ function makeChecker(expectedForm: any, expectedFormUrl: string, options?: { par
465465
? prettier.format(JSON.stringify(suggestion), { tabWidth: 4, filepath: ".json" })
466466
: JSON.stringify(suggestion, undefined, 4) + "\n"
467467
).split(/^/m);
468-
const lines = contents.split(/^/m);
468+
const lines = newText.split(/^/m);
469469
// When suggestionLines is empty, that suggests removing all
470470
// of the different lines
471471
let startLine = 1;

0 commit comments

Comments
 (0)