From ecaf7924245cf7891c54ca1ffffc96ee6d6aa298 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Mon, 14 Oct 2024 16:52:52 +1100 Subject: [PATCH] Placate linter --- .changeset/changelog.js | 24 +++++++++++------------- src/serializers/index.test.ts | 1 + 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.changeset/changelog.js b/.changeset/changelog.js index b6ec92e..c8d731f 100644 --- a/.changeset/changelog.js +++ b/.changeset/changelog.js @@ -70,11 +70,11 @@ const gitHubChangelogFunctions = { await Promise.all( changesets.map(async (cs) => { if (cs.commit) { - let { links } = await getInfo({ + const info = await getInfo({ repo: options.repo, commit: cs.commit, }); - return links.commit; + return info.links.commit; } }), ) @@ -102,7 +102,7 @@ const gitHubChangelogFunctions = { const replacedChangelog = changeset.summary .replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => { - let num = Number(pr); + const num = Number(pr); if (!isNaN(num)) prFromSummary = num; return ''; }) @@ -110,10 +110,7 @@ const gitHubChangelogFunctions = { commitFromSummary = commit; return ''; }) - .replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => { - usersFromSummary.push(user); - return ''; - }) + .replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, '') .trim(); const [firstLine, ...futureLines] = replacedChangelog @@ -122,25 +119,25 @@ const gitHubChangelogFunctions = { const links = await (async () => { if (prFromSummary !== undefined) { - let { links } = await getInfoFromPullRequest({ + const info = await getInfoFromPullRequest({ repo: options.repo, pull: prFromSummary, }); if (commitFromSummary) { - links = { - ...links, + return { + ...info.links, commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`, }; } - return links; + return info.links; } const commitToFetchFrom = commitFromSummary || changeset.commit; if (commitToFetchFrom) { - let { links } = await getInfo({ + const info = await getInfo({ repo: options.repo, commit: commitToFetchFrom, }); - return links; + return info.links; } return { commit: null, @@ -163,6 +160,7 @@ const gitHubChangelogFunctions = { if (process.env.GITHUB_TOKEN) { module.exports = gitHubChangelogFunctions; } else { + // eslint-disable-next-line no-console console.warn( `Defaulting to Git-based versioning. Enable GitHub-based versioning by setting the GITHUB_TOKEN environment variable. diff --git a/src/serializers/index.test.ts b/src/serializers/index.test.ts index 0b921b1..dea2534 100644 --- a/src/serializers/index.test.ts +++ b/src/serializers/index.test.ts @@ -15,6 +15,7 @@ describe('DEFAULT_OMIT_HEADER_NAMES', () => { expect(() => { // @ts-expect-error - We're trying to break the read-only array (TS2542). + // eslint-disable-next-line @typescript-eslint/no-array-delete delete DEFAULT_OMIT_HEADER_NAMES[0]; }).toThrowErrorMatchingInlineSnapshot( `"Cannot delete property '0' of [object Array]"`,