Housekeeping + Make ESLint Happy

This commit is contained in:
SukkaW
2024-09-05 22:22:28 +08:00
parent f07cf055e5
commit ae732735ef
5 changed files with 272 additions and 185 deletions

View File

@@ -10,7 +10,7 @@ export const HOSTS: HostsSource[] = [
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Xiaomi-Extension.txt', null, false, TTL.THREE_DAYS()],
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Huawei-AdBlock.txt', null, false, TTL.THREE_DAYS()],
['https://raw.githubusercontent.com/durablenapkin/block/master/luminati.txt', null, true, TTL.THREE_HOURS()]
] as const;
];
export const HOSTS_EXTRA: HostsSource[] = [
// This stupid hosts blocks t.co, so we determine that this is also bullshit, so it is also extra
@@ -40,7 +40,7 @@ export const DOMAIN_LISTS: HostsSource[] = [
],
true, TTL.THREE_HOURS()
]
] as const;
];
export const DOMAIN_LISTS_EXTRA: HostsSource[] = [
// BarbBlock
@@ -84,7 +84,7 @@ export const PHISHING_DOMAIN_LISTS_EXTRA: [HostsSource, HostsSource] = [
[],
true, TTL.THREE_HOURS()
]
] as const;
];
type AdGuardFilterSource = [main: string, mirrors: string[] | null, ttl: number];
@@ -147,7 +147,7 @@ export const ADGUARD_FILTERS: AdGuardFilterSource[] = [
['https://raw.githubusercontent.com/Spam404/lists/master/adblock-list.txt', null, TTL.TEN_DAYS()],
// Brave First Party & First Party CNAME
['https://raw.githubusercontent.com/brave/adblock-lists/master/brave-lists/brave-firstparty.txt', null, TTL.ONE_DAY()]
] as const;
];
export const ADGUARD_FILTERS_EXTRA: AdGuardFilterSource[] = [
// AdGuard Annoyances filter

View File

@@ -2,12 +2,8 @@ import picocolors from 'picocolors';
import { defaultRequestInit, fetchWithRetry } from './fetch-retry';
import { setTimeout } from 'node:timers/promises';
// eslint-disable-next-line sukka/unicorn/custom-error-definition -- typescript is better
class CustomAbortError extends Error {
constructor() {
super();
this.name = 'CustomAbortError';
}
public readonly name = 'AbortError';
public readonly digest = 'AbortError';
}
@@ -18,10 +14,12 @@ const sleepWithAbort = (ms: number, signal: AbortSignal) => new Promise<void>((r
return;
}
function stop(this: AbortSignal) { reject(this.reason as Error); }
signal.addEventListener('abort', stop, { once: true });
// eslint-disable-next-line sukka/prefer-timer-id -- node:timers/promises
setTimeout(ms, undefined, { ref: false }).then(resolve).catch(reject).finally(() => signal.removeEventListener('abort', stop));
function stop(this: AbortSignal) { reject(this.reason as Error); }
});
export async function fetchAssets(url: string, fallbackUrls: string[] | readonly string[]) {

View File

@@ -63,7 +63,7 @@ export class TextLineStream extends TransformStream<string, string> {
},
flush(controller) {
if (__buf.length > 0) {
// eslint-disable-next-line sukka-ts/string/prefer-string-starts-ends-with -- performance
// eslint-disable-next-line sukka/string/prefer-string-starts-ends-with -- performance
if (allowCR && __buf[__buf.length - 1] === '\r') {
controller.enqueue(__buf.slice(0, -1));
} else {