mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
chore: fix leftover eslint exceptions
This commit is contained in:
@@ -58,7 +58,6 @@ const sublimit = { body: { name: 'newname' } };
|
||||
const noSublimit = { body: { bitrate: 40_000 } };
|
||||
|
||||
function startSublimitIntervals() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (!sublimitIntervals.reset) {
|
||||
sublimitResetAfter = Date.now() + 250;
|
||||
sublimitIntervals.reset = setInterval(() => {
|
||||
@@ -67,7 +66,6 @@ function startSublimitIntervals() {
|
||||
}, 250);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (!sublimitIntervals.retry) {
|
||||
retryAfter = Date.now() + 1_000;
|
||||
sublimitIntervals.retry = setInterval(() => {
|
||||
|
||||
@@ -62,7 +62,7 @@ test('resolveBody', async () => {
|
||||
};
|
||||
await expect(resolveBody(asyncIterable)).resolves.toStrictEqual(Buffer.from([1, 2, 3, 1, 2, 3, 1, 2, 3]));
|
||||
|
||||
// unknown type
|
||||
// @ts-expect-error This test is ensuring that this throws
|
||||
// Unknown type
|
||||
// @ts-expect-error: This test is ensuring that this throws
|
||||
await expect(resolveBody(true)).rejects.toThrow(TypeError);
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
type RequestData,
|
||||
type RouteLike,
|
||||
} from './RequestManager.js';
|
||||
import type { IHandler } from './handlers/IHandler';
|
||||
import type { IHandler } from './handlers/IHandler.js';
|
||||
import { DefaultRestOptions, RESTEvents } from './utils/constants.js';
|
||||
import { parseResponse } from './utils/utils.js';
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import type { URLSearchParams } from 'node:url';
|
||||
import { Collection } from '@discordjs/collection';
|
||||
import { DiscordSnowflake } from '@sapphire/snowflake';
|
||||
import { FormData, type RequestInit, type BodyInit, type Dispatcher, type Agent } from 'undici';
|
||||
import type { RESTOptions, RestEvents, RequestOptions } from './REST';
|
||||
import type { IHandler } from './handlers/IHandler';
|
||||
import type { RESTOptions, RestEvents, RequestOptions } from './REST.js';
|
||||
import type { IHandler } from './handlers/IHandler.js';
|
||||
import { SequentialHandler } from './handlers/SequentialHandler.js';
|
||||
import { DefaultRestOptions, DefaultUserAgent, RESTEvents } from './utils/constants.js';
|
||||
import { resolveBody } from './utils/utils.js';
|
||||
@@ -208,7 +208,6 @@ export class RequestManager extends EventEmitter {
|
||||
*/
|
||||
public readonly handlers = new Collection<string, IHandler>();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
||||
#token: string | null = null;
|
||||
|
||||
private hashTimer!: NodeJS.Timer;
|
||||
@@ -422,7 +421,6 @@ export class RequestManager extends EventEmitter {
|
||||
const contentType = file.contentType ?? (await fileTypeFromBuffer(file.data))?.mime;
|
||||
formData.append(fileKey, new Blob([file.data], { type: contentType }), file.name);
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name);
|
||||
}
|
||||
}
|
||||
@@ -457,7 +455,6 @@ export class RequestManager extends EventEmitter {
|
||||
finalBody = await resolveBody(finalBody);
|
||||
|
||||
const fetchOptions: RequestOptions = {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
headers: { ...request.headers, ...additionalHeaders, ...headers } as Record<string, string>,
|
||||
method: request.method.toUpperCase() as Dispatcher.HttpMethod,
|
||||
};
|
||||
|
||||
@@ -101,13 +101,11 @@ export class DiscordAPIError extends Error {
|
||||
|
||||
if (typeof val === 'string') {
|
||||
yield val;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
} else if (isErrorGroupWrapper(val)) {
|
||||
for (const error of val._errors) {
|
||||
yield* this.flattenDiscordError(error, nextKey);
|
||||
}
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
yield* this.flattenDiscordError(val, nextKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ export interface IHandler {
|
||||
/**
|
||||
* If the bucket is currently inactive (no pending requests)
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/method-signature-style -- This is meant to be a getter returning a bool
|
||||
get inactive(): boolean;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
|
||||
@@ -53,25 +53,21 @@ export class SequentialHandler implements IHandler {
|
||||
/**
|
||||
* The interface used to sequence async requests sequentially
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
||||
#asyncQueue = new AsyncQueue();
|
||||
|
||||
/**
|
||||
* The interface used to sequence sublimited async requests sequentially
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
||||
#sublimitedQueue: AsyncQueue | null = null;
|
||||
|
||||
/**
|
||||
* A promise wrapper for when the sublimited queue is finished being processed or null when not being processed
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
||||
#sublimitPromise: { promise: Promise<void>; resolve(): void } | null = null;
|
||||
|
||||
/**
|
||||
* Whether the sublimit queue needs to be shifted in the finally block
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
||||
#shiftSublimit = false;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,10 +2,9 @@ import process from 'node:process';
|
||||
import { APIVersion } from 'discord-api-types/v10';
|
||||
import { getGlobalDispatcher } from 'undici';
|
||||
import type { RESTOptions } from '../REST.js';
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
||||
const Package = require('../../../package.json');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access
|
||||
export const DefaultUserAgent = `DiscordBot (${Package.homepage}, ${Package.version})`;
|
||||
|
||||
export const DefaultRestOptions: Required<RESTOptions> = {
|
||||
|
||||
@@ -113,7 +113,6 @@ export async function resolveBody(body: RequestInit['body']): Promise<RequestOpt
|
||||
return new Uint8Array(await body.arrayBuffer());
|
||||
} else if (body instanceof FormData) {
|
||||
return body;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {
|
||||
const chunks = [...(body as Iterable<Uint8Array>)];
|
||||
const length = chunks.reduce((a, b) => a + b.length, 0);
|
||||
@@ -126,7 +125,6 @@ export async function resolveBody(body: RequestInit['body']): Promise<RequestOpt
|
||||
lengthUsed += b.length;
|
||||
return a;
|
||||
}, uint8);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {
|
||||
const chunks: Uint8Array[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user