mirror of
https://github.com/SukkaW/Surge.git
synced 2026-09-12 18:44:36 +08:00
Housekeeping & Make ESLint Happy
This commit is contained in:
@@ -265,7 +265,8 @@ function parseArguments(args: string[]) {
|
|||||||
let modes: BenchmarkMode[] = ['fetch', 'request'];
|
let modes: BenchmarkMode[] = ['fetch', 'request'];
|
||||||
const urls: string[] = [];
|
const urls: string[] = [];
|
||||||
|
|
||||||
for (const arg of args) {
|
for (let i = 0, len = args.length; i < len; i++) {
|
||||||
|
const arg = args[i];
|
||||||
if (arg === '--') {
|
if (arg === '--') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -334,7 +335,8 @@ async function main() {
|
|||||||
// Use fresh Agents and discard both results. This primes shared DNS/CDN
|
// Use fresh Agents and discard both results. This primes shared DNS/CDN
|
||||||
// state and initializes both APIs without carrying HTTP connections into
|
// state and initializes both APIs without carrying HTTP connections into
|
||||||
// measured rounds.
|
// 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
|
// eslint-disable-next-line no-await-in-loop -- warm-up is intentionally isolated per mode
|
||||||
await runMode(mode, urls, concurrency, encoding, 'warmup', false);
|
await runMode(mode, urls, concurrency, encoding, 'warmup', false);
|
||||||
}
|
}
|
||||||
@@ -347,14 +349,16 @@ async function main() {
|
|||||||
// later in the trial.
|
// later in the trial.
|
||||||
const roundModes = round % 2 === 0 ? modes.toReversed() : modes;
|
const roundModes = round % 2 === 0 ? modes.toReversed() : modes;
|
||||||
console.log('[download benchmark:round]', `round=${round}`, `order=${roundModes.join(',')}`);
|
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
|
// eslint-disable-next-line no-await-in-loop -- modes intentionally run separately for comparable totals
|
||||||
const result = await runMode(mode, urls, concurrency, encoding, round);
|
const result = await runMode(mode, urls, concurrency, encoding, round);
|
||||||
results.get(mode)?.push(result);
|
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) ?? []);
|
printModeSummary(mode, results.get(mode) ?? []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 })));
|
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 = [
|
const content = [
|
||||||
'#########################################',
|
'#########################################',
|
||||||
'# Sukka\'s Ruleset - Deprecated',
|
'# Sukka\'s Ruleset - Deprecated',
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ export const buildAlwaysRealIPModule = task(require.main === module, __filename)
|
|||||||
|
|
||||||
const getDnsMappingRuleWithoutWildcard = createGetDnsMappingRule(false);
|
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));
|
clashFakeIpFilter.addFromRuleset(domains.flatMap(getDnsMappingRuleWithoutWildcard));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ export class AdGuardHome extends BaseWriteStrategy {
|
|||||||
// So we can't do noResolve
|
// So we can't do noResolve
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const ipcidr of ipGroup) {
|
for (let i = 0, len = ipGroup.length; i < len; i++) {
|
||||||
|
const ipcidr = ipGroup[i];
|
||||||
if (ipcidr.endsWith('/32')) {
|
if (ipcidr.endsWith('/32')) {
|
||||||
this.result.push(`||${ipcidr.slice(0, -3)}`);
|
this.result.push(`||${ipcidr.slice(0, -3)}`);
|
||||||
/* else if (ipcidr.endsWith('.0/24')) {
|
/* else if (ipcidr.endsWith('.0/24')) {
|
||||||
@@ -89,7 +90,8 @@ export class AdGuardHome extends BaseWriteStrategy {
|
|||||||
// So we can't do noResolve
|
// So we can't do noResolve
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const ipcidr of ipGroup) {
|
for (let i = 0, len = ipGroup.length; i < len; i++) {
|
||||||
|
const ipcidr = ipGroup[i];
|
||||||
if (ipcidr.endsWith('/128')) {
|
if (ipcidr.endsWith('/128')) {
|
||||||
this.result.push(`||${ipcidr.slice(0, -4)}`);
|
this.result.push(`||${ipcidr.slice(0, -4)}`);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy {
|
|||||||
return newCombinations;
|
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 match = matches[i];
|
||||||
const [_, ...options] = match;
|
const [_, ...options] = match;
|
||||||
|
|
||||||
@@ -245,8 +245,10 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const i of urlRegexResults) {
|
for (let i = 0, len = urlRegexResults.length; i < len; i++) {
|
||||||
for (const processed of i.processed) {
|
const result = urlRegexResults[i];
|
||||||
|
for (let j = 0, len2 = result.processed.length; j < len2; j++) {
|
||||||
|
const processed = result.processed[j];
|
||||||
if (
|
if (
|
||||||
normalizeDomain(
|
normalizeDomain(
|
||||||
processed
|
processed
|
||||||
@@ -254,9 +256,9 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy {
|
|||||||
.replaceAll('?', 'b')
|
.replaceAll('?', 'b')
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
parsed.push([i.origin, processed]);
|
parsed.push([result.origin, processed]);
|
||||||
} else if (!isProbablyIpv4(processed)) {
|
} else if (!isProbablyIpv4(processed)) {
|
||||||
parsedFailures.push([i.origin, processed]);
|
parsedFailures.push([result.origin, processed]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,7 +201,8 @@ function mergeWorkerTrace(
|
|||||||
workerTimeOrigin: number
|
workerTimeOrigin: number
|
||||||
): void {
|
): void {
|
||||||
const offset = workerTimeOrigin - performance.timeOrigin;
|
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));
|
parentSpan.traceResult.children.push(adjustTraceTimestamps(child, offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ function writeJobSummary(shardLabel: string, dead: string[], geo: RunnerGeoIP |
|
|||||||
const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
||||||
bar.start(shardDomains.length, 0);
|
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 () => {
|
queue.add(async () => {
|
||||||
let registerableDomainAlive, registerableDomain, alive: boolean | undefined;
|
let registerableDomainAlive, registerableDomain, alive: boolean | undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,9 @@ export async function parseGfwList() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const text = await (await $$fetch('https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt')).text();
|
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);
|
const line = processLine(l);
|
||||||
if (!line) continue;
|
if (!line) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import { xxhash3 } from 'hash-wasm';
|
|||||||
const hashMap = new Map<string, Set<string>>();
|
const hashMap = new Map<string, Set<string>>();
|
||||||
|
|
||||||
const runHash = async (inputs: string[]) => {
|
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);
|
const hash = await xxhash3(input);
|
||||||
if (!hashMap.has(hash)) {
|
if (!hashMap.has(hash)) {
|
||||||
hashMap.set(hash, new Set());
|
hashMap.set(hash, new Set());
|
||||||
@@ -23,7 +24,8 @@ import { xxhash3 } from 'hash-wasm';
|
|||||||
.crawl(OUTPUT_SURGE_DIR)
|
.crawl(OUTPUT_SURGE_DIR)
|
||||||
.withPromise();
|
.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);
|
const fullpath = path.join(OUTPUT_SURGE_DIR, file);
|
||||||
if (file.startsWith('domainset' + path.sep)) {
|
if (file.startsWith('domainset' + path.sep)) {
|
||||||
await runHash((await readFileIntoProcessedArray(fullpath)).map(i => (i[0] === '.' ? i.slice(1) : i)));
|
await runHash((await readFileIntoProcessedArray(fullpath)).map(i => (i[0] === '.' ? i.slice(1) : i)));
|
||||||
|
|||||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -1338,8 +1338,8 @@ packages:
|
|||||||
'@typescript-eslint/eslint-plugin':
|
'@typescript-eslint/eslint-plugin':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
eslint-plugin-vibe-proof@1.0.0:
|
eslint-plugin-vibe-proof@1.2.0:
|
||||||
resolution: {integrity: sha512-vEjcAyzylbTmXhAo9eOuhgEM8cs0OG+Rs2L45yhehhtS466sDV0QyiJB8VzQdAGyLNMZQ1EfrdpINAdg5XBodQ==}
|
resolution: {integrity: sha512-lC/pxwfj1ARdRiFsGzi4OD8IHkHjJWBKbgwfoSsevDDOA8TRiIFp+8+KriGj5X3/sfi7epqYJOCRv8hTb9Ympw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: '>=9.29.0'
|
eslint: '>=9.29.0'
|
||||||
typescript: '*'
|
typescript: '*'
|
||||||
@@ -3204,7 +3204,7 @@ snapshots:
|
|||||||
'@typescript-eslint/types': 8.65.0
|
'@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)
|
'@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: 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
|
foxts: 5.8.0
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -3216,12 +3216,12 @@ snapshots:
|
|||||||
optionalDependencies:
|
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)
|
'@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:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.65.0
|
'@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)
|
'@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: 10.8.0(supports-color@8.1.1)
|
||||||
foxts: 5.8.0
|
foxts: 5.8.1
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|||||||
Reference in New Issue
Block a user