1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Enable github/array-foreach ESLint rule by converting all forEach to for loops (#58302)

Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
This commit is contained in:
Kevin Heis
2025-11-12 11:18:21 -08:00
committed by GitHub
parent 86216fb38b
commit 8adc699635
124 changed files with 777 additions and 718 deletions

View File

@@ -399,7 +399,9 @@ async function getIndexFileVersions(
throw new Error(`Frontmatter in ${filepath} does not contain versions.`)
}
const fmVersions = getApplicableVersions(data.versions)
fmVersions.forEach((version: string) => versions.add(version))
for (const version of fmVersions) {
versions.add(version)
}
}),
)
const versionArray = [...versions]
@@ -431,7 +433,7 @@ export async function convertVersionsToFrontmatter(
// Currently, only GHES is numbered. Number releases have to be
// handled differently because they use semantic versioning.
versions.forEach((version) => {
for (const version of versions) {
const docsVersion = allVersions[version]
if (!docsVersion.hasNumberedReleases) {
frontmatterVersions[docsVersion.shortName] = '*'
@@ -455,10 +457,10 @@ export async function convertVersionsToFrontmatter(
numberedReleases[docsVersion.shortName].availableReleases[i] = docsVersion.currentRelease
}
}
})
}
// Create semantic versions for numbered releases
Object.keys(numberedReleases).forEach((key) => {
for (const key of Object.keys(numberedReleases)) {
const availableReleases = numberedReleases[key].availableReleases
const versionContinuity = checkVersionContinuity(availableReleases)
if (availableReleases.every(Boolean)) {
@@ -483,7 +485,7 @@ export async function convertVersionsToFrontmatter(
}
frontmatterVersions[key] = semVer.join(' ')
}
})
}
const sortedFrontmatterVersions = Object.keys(frontmatterVersions)
.sort()
.reduce((acc: { [key: string]: string }, key) => {

View File

@@ -88,9 +88,9 @@ describe('automated content directory updates', () => {
// Because of that, we need to update the content paths to use the
// full file path.
const contentDataFullPath: { [key: string]: ContentItem } = {}
Object.keys(newContentData).forEach(
(key: string) => (contentDataFullPath[path.join(targetDirectory, key)] = newContentData[key]),
)
for (const key of Object.keys(newContentData)) {
contentDataFullPath[path.join(targetDirectory, key)] = newContentData[key]
}
// Rewrites the content directory in the operating system's
// temp directory.