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,6 +1,7 @@
import process from 'node:process';
import { APIVersion } from 'discord-api-types/v10';
import { getGlobalDispatcher } from 'undici';
import type { RESTOptions } from '../REST';
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
const Package = require('../../../package.json');
@@ -33,16 +34,16 @@ export const DefaultRestOptions: Required<RESTOptions> = {
*/
export const enum RESTEvents {
Debug = 'restDebug',
HandlerSweep = 'handlerSweep',
HashSweep = 'hashSweep',
InvalidRequestWarning = 'invalidRequestWarning',
RateLimited = 'rateLimited',
Response = 'response',
HashSweep = 'hashSweep',
HandlerSweep = 'handlerSweep',
}
export const ALLOWED_EXTENSIONS = ['webp', 'png', 'jpg', 'jpeg', 'gif'] as const;
export const ALLOWED_STICKER_EXTENSIONS = ['png', 'json'] as const;
export const ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096] as const;
export const ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1_024, 2_048, 4_096] as const;
export type ImageExtension = typeof ALLOWED_EXTENSIONS[number];
export type StickerExtension = typeof ALLOWED_STICKER_EXTENSIONS[number];

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