diff --git a/Build/benchmark-download-client.ts b/Build/benchmark-download-client.ts index 3211c410..0a1f009a 100644 --- a/Build/benchmark-download-client.ts +++ b/Build/benchmark-download-client.ts @@ -265,7 +265,8 @@ function parseArguments(args: string[]) { let modes: BenchmarkMode[] = ['fetch', 'request']; const urls: string[] = []; - for (const arg of args) { + for (let i = 0, len = args.length; i < len; i++) { + const arg = args[i]; if (arg === '--') { continue; } @@ -334,7 +335,8 @@ async function main() { // Use fresh Agents and discard both results. This primes shared DNS/CDN // state and initializes both APIs without carrying HTTP connections into // measured rounds. - for (const mode of modes) { + for (let i = 0, len = modes.length; i < len; i++) { + const mode = modes[i]; // eslint-disable-next-line no-await-in-loop -- warm-up is intentionally isolated per mode await runMode(mode, urls, concurrency, encoding, 'warmup', false); } @@ -347,14 +349,16 @@ async function main() { // later in the trial. const roundModes = round % 2 === 0 ? modes.toReversed() : modes; console.log('[download benchmark:round]', `round=${round}`, `order=${roundModes.join(',')}`); - for (const mode of roundModes) { + for (let i = 0, len = roundModes.length; i < len; i++) { + const mode = roundModes[i]; // eslint-disable-next-line no-await-in-loop -- modes intentionally run separately for comparable totals const result = await runMode(mode, urls, concurrency, encoding, round); results.get(mode)?.push(result); } } - for (const mode of modes) { + for (let i = 0, len = modes.length; i < len; i++) { + const mode = modes[i]; printModeSummary(mode, results.get(mode) ?? []); } } diff --git a/Build/build-deprecate-files.ts b/Build/build-deprecate-files.ts index 64ca63c7..711299bf 100644 --- a/Build/build-deprecate-files.ts +++ b/Build/build-deprecate-files.ts @@ -35,7 +35,8 @@ export const buildDeprecateFiles = task(require.main === module, __filename)((sp appendArrayInPlace(promises, REMOVED_FOLDERS.map(folder => fsp.rm(path.join(PUBLIC_DIR, folder), { force: true, recursive: true }))); - for (const [filePath, description] of DEPRECATED_FILES) { + for (let i = 0, len = DEPRECATED_FILES.length; i < len; i++) { + const [filePath, description] = DEPRECATED_FILES[i]; const content = [ '#########################################', '# Sukka\'s Ruleset - Deprecated', diff --git a/Build/build-sgmodule-always-realip.ts b/Build/build-sgmodule-always-realip.ts index 4f8a5b4d..5a26f693 100644 --- a/Build/build-sgmodule-always-realip.ts +++ b/Build/build-sgmodule-always-realip.ts @@ -73,7 +73,8 @@ export const buildAlwaysRealIPModule = task(require.main === module, __filename) const getDnsMappingRuleWithoutWildcard = createGetDnsMappingRule(false); - for (const { domains } of dataset) { + for (let i = 0, len = dataset.length; i < len; i++) { + const { domains } = dataset[i]; clashFakeIpFilter.addFromRuleset(domains.flatMap(getDnsMappingRuleWithoutWildcard)); } diff --git a/Build/lib/writing-strategy/adguardhome.ts b/Build/lib/writing-strategy/adguardhome.ts index 82eaa169..0906b5aa 100644 --- a/Build/lib/writing-strategy/adguardhome.ts +++ b/Build/lib/writing-strategy/adguardhome.ts @@ -71,7 +71,8 @@ export class AdGuardHome extends BaseWriteStrategy { // So we can't do noResolve return; } - for (const ipcidr of ipGroup) { + for (let i = 0, len = ipGroup.length; i < len; i++) { + const ipcidr = ipGroup[i]; if (ipcidr.endsWith('/32')) { this.result.push(`||${ipcidr.slice(0, -3)}`); /* else if (ipcidr.endsWith('.0/24')) { @@ -89,7 +90,8 @@ export class AdGuardHome extends BaseWriteStrategy { // So we can't do noResolve return; } - for (const ipcidr of ipGroup) { + for (let i = 0, len = ipGroup.length; i < len; i++) { + const ipcidr = ipGroup[i]; if (ipcidr.endsWith('/128')) { this.result.push(`||${ipcidr.slice(0, -4)}`); } else { diff --git a/Build/lib/writing-strategy/surge.ts b/Build/lib/writing-strategy/surge.ts index f8026163..767013a1 100644 --- a/Build/lib/writing-strategy/surge.ts +++ b/Build/lib/writing-strategy/surge.ts @@ -231,7 +231,7 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy { return newCombinations; }; - for (let i = 0; i < matches.length; i++) { + for (let i = 0, len = matches.length; i < len; i++) { const match = matches[i]; const [_, ...options] = match; @@ -245,8 +245,10 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy { }); } - for (const i of urlRegexResults) { - for (const processed of i.processed) { + for (let i = 0, len = urlRegexResults.length; i < len; i++) { + const result = urlRegexResults[i]; + for (let j = 0, len2 = result.processed.length; j < len2; j++) { + const processed = result.processed[j]; if ( normalizeDomain( processed @@ -254,9 +256,9 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy { .replaceAll('?', 'b') ) ) { - parsed.push([i.origin, processed]); + parsed.push([result.origin, processed]); } else if (!isProbablyIpv4(processed)) { - parsedFailures.push([i.origin, processed]); + parsedFailures.push([result.origin, processed]); } } } diff --git a/Build/trace/index.ts b/Build/trace/index.ts index 45efe428..c2cf1151 100644 --- a/Build/trace/index.ts +++ b/Build/trace/index.ts @@ -201,7 +201,8 @@ function mergeWorkerTrace( workerTimeOrigin: number ): void { const offset = workerTimeOrigin - performance.timeOrigin; - for (const child of workerTraceResult.children) { + for (let i = 0, len = workerTraceResult.children.length; i < len; i++) { + const child = workerTraceResult.children[i]; parentSpan.traceResult.children.push(adjustTraceTimestamps(child, offset)); } } diff --git a/Build/validate-domain-alive.ts b/Build/validate-domain-alive.ts index f9f4fa8b..5f952637 100644 --- a/Build/validate-domain-alive.ts +++ b/Build/validate-domain-alive.ts @@ -71,7 +71,8 @@ function writeJobSummary(shardLabel: string, dead: string[], geo: RunnerGeoIP | const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic); bar.start(shardDomains.length, 0); - for (const { domain, includeAllSubdomain } of shardDomains) { + for (let i = 0, len = shardDomains.length; i < len; i++) { + const { domain, includeAllSubdomain } = shardDomains[i]; queue.add(async () => { let registerableDomainAlive, registerableDomain, alive: boolean | undefined; diff --git a/Build/validate-gfwlist.ts b/Build/validate-gfwlist.ts index 90bea794..f95f5fa4 100644 --- a/Build/validate-gfwlist.ts +++ b/Build/validate-gfwlist.ts @@ -70,7 +70,9 @@ export async function parseGfwList() { ]); const text = await (await $$fetch('https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt')).text(); - for (const l of atob(text).split('\n')) { + const lines = atob(text).split('\n'); + for (let i = 0, len = lines.length; i < len; i++) { + const l = lines[i]; const line = processLine(l); if (!line) continue; diff --git a/Build/validate-hash-collision-test.ts b/Build/validate-hash-collision-test.ts index fd2e1daa..85cbc484 100644 --- a/Build/validate-hash-collision-test.ts +++ b/Build/validate-hash-collision-test.ts @@ -9,7 +9,8 @@ import { xxhash3 } from 'hash-wasm'; const hashMap = new Map>(); const runHash = async (inputs: string[]) => { - for (const input of inputs) { + for (let i = 0, len = inputs.length; i < len; i++) { + const input = inputs[i]; const hash = await xxhash3(input); if (!hashMap.has(hash)) { hashMap.set(hash, new Set()); @@ -23,7 +24,8 @@ import { xxhash3 } from 'hash-wasm'; .crawl(OUTPUT_SURGE_DIR) .withPromise(); - for (const file of files) { + for (let i = 0, len = files.length; i < len; i++) { + const file = files[i]; const fullpath = path.join(OUTPUT_SURGE_DIR, file); if (file.startsWith('domainset' + path.sep)) { await runHash((await readFileIntoProcessedArray(fullpath)).map(i => (i[0] === '.' ? i.slice(1) : i))); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d711ee30..1de32cb4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1338,8 +1338,8 @@ packages: '@typescript-eslint/eslint-plugin': optional: true - eslint-plugin-vibe-proof@1.0.0: - resolution: {integrity: sha512-vEjcAyzylbTmXhAo9eOuhgEM8cs0OG+Rs2L45yhehhtS466sDV0QyiJB8VzQdAGyLNMZQ1EfrdpINAdg5XBodQ==} + eslint-plugin-vibe-proof@1.2.0: + resolution: {integrity: sha512-lC/pxwfj1ARdRiFsGzi4OD8IHkHjJWBKbgwfoSsevDDOA8TRiIFp+8+KriGj5X3/sfi7epqYJOCRv8hTb9Ympw==} peerDependencies: eslint: '>=9.29.0' typescript: '*' @@ -3204,7 +3204,7 @@ snapshots: '@typescript-eslint/types': 8.65.0 '@typescript-eslint/utils': 8.65.0(eslint@10.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3) eslint: 10.8.0(supports-color@8.1.1) - eslint-plugin-vibe-proof: 1.0.0(eslint@10.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3) + eslint-plugin-vibe-proof: 1.2.0(eslint@10.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3) foxts: 5.8.0 typescript: 6.0.3 transitivePeerDependencies: @@ -3216,12 +3216,12 @@ snapshots: optionalDependencies: '@typescript-eslint/eslint-plugin': 8.65.0(@typescript-eslint/parser@8.65.0(eslint@10.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3))(eslint@10.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3) - eslint-plugin-vibe-proof@1.0.0(eslint@10.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3): + eslint-plugin-vibe-proof@1.2.0(eslint@10.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3): dependencies: '@typescript-eslint/types': 8.65.0 '@typescript-eslint/utils': 8.65.0(eslint@10.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3) eslint: 10.8.0(supports-color@8.1.1) - foxts: 5.8.0 + foxts: 5.8.1 typescript: 6.0.3 transitivePeerDependencies: - supports-color