refactor: use eslint-config-neon for packages. (#8579)

Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
Suneet Tipirneni
2022-09-01 14:50:16 -04:00
committed by GitHub
parent 4bdb0593ae
commit edadb9fe5d
219 changed files with 2608 additions and 2053 deletions

View File

@@ -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') {