mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
refactor: use eslint-config-neon for packages. (#8579)
Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { Blob } from 'node:buffer';
|
||||
import { Blob, Buffer } from 'node:buffer';
|
||||
import { URLSearchParams } from 'node:url';
|
||||
import { types } from 'node:util';
|
||||
import type { RESTPatchAPIChannelJSONBody } from 'discord-api-types/v10';
|
||||
import { FormData, type Dispatcher, type RequestInit } from 'undici';
|
||||
import type { RequestOptions } from '../REST';
|
||||
import { RequestMethod } from '../RequestManager';
|
||||
import type { RequestOptions } from '../REST.js';
|
||||
import { RequestMethod } from '../RequestManager.js';
|
||||
|
||||
export function parseHeader(header: string | string[] | undefined): string | undefined {
|
||||
export function parseHeader(header: string[] | string | undefined): string | undefined {
|
||||
if (header === undefined) {
|
||||
return header;
|
||||
} else if (typeof header === 'string') {
|
||||
@@ -29,6 +29,7 @@ function serializeSearchParam(value: unknown): string | null {
|
||||
if (value instanceof Date) {
|
||||
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
||||
if (typeof value.toString === 'function' && value.toString !== Object.prototype.toString) return value.toString();
|
||||
return null;
|
||||
@@ -42,7 +43,6 @@ function serializeSearchParam(value: unknown): string | null {
|
||||
* out null and undefined values, while also coercing non-strings to strings.
|
||||
*
|
||||
* @param options - The options to use
|
||||
*
|
||||
* @returns A populated URLSearchParams instance
|
||||
*/
|
||||
export function makeURLSearchParams(options?: Record<string, unknown>) {
|
||||
@@ -62,7 +62,7 @@ export function makeURLSearchParams(options?: Record<string, unknown>) {
|
||||
*
|
||||
* @param res - The fetch response
|
||||
*/
|
||||
export function parseResponse(res: Dispatcher.ResponseData): Promise<unknown> {
|
||||
export async function parseResponse(res: Dispatcher.ResponseData): Promise<unknown> {
|
||||
const header = parseHeader(res.headers['content-type']);
|
||||
if (header?.startsWith('application/json')) {
|
||||
return res.body.json();
|
||||
@@ -77,7 +77,6 @@ export function parseResponse(res: Dispatcher.ResponseData): Promise<unknown> {
|
||||
* @param bucketRoute - The buckets route identifier
|
||||
* @param body - The options provided as JSON data
|
||||
* @param method - The HTTP method that will be used to make the request
|
||||
*
|
||||
* @returns Whether the request falls under a sublimit
|
||||
*/
|
||||
export function hasSublimit(bucketRoute: string, body?: unknown, method?: string): boolean {
|
||||
@@ -97,7 +96,7 @@ export function hasSublimit(bucketRoute: string, body?: unknown, method?: string
|
||||
}
|
||||
|
||||
export async function resolveBody(body: RequestInit['body']): Promise<RequestOptions['body']> {
|
||||
// eslint-disable-next-line no-eq-null
|
||||
// eslint-disable-next-line no-eq-null, eqeqeq
|
||||
if (body == null) {
|
||||
return null;
|
||||
} else if (typeof body === 'string') {
|
||||
|
||||
Reference in New Issue
Block a user