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,11 +1,18 @@
import { URL } from 'node:url';
import { DiscordAPIError, HTTPError, RateLimitError, RequestMethod, REST, RouteLike } from '@discordjs/rest';
import {
DiscordAPIError,
HTTPError,
RateLimitError,
type RequestMethod,
type REST,
type RouteLike,
} from '@discordjs/rest';
import {
populateAbortErrorResponse,
populateGeneralErrorResponse,
populateSuccessfulResponse,
populateRatelimitErrorResponse,
} from '../util/responseHelpers';
} from '../util/responseHelpers.js';
import type { RequestHandler } from '../util/util';
/**
@@ -25,6 +32,7 @@ export function proxyRequests(rest: REST): RequestHandler {
// The 2nd parameter is here so the URL constructor doesn't complain about an "invalid url" when the origin is missing
// we don't actually care about the origin and the value passed is irrelevant
// eslint-disable-next-line prefer-named-capture-group, unicorn/no-unsafe-regex
const fullRoute = new URL(url, 'http://noop').pathname.replace(/^\/api(\/v\d+)?/, '') as RouteLike;
try {

View File

@@ -1,3 +1,3 @@
export * from './handlers/proxyRequests';
export * from './util/responseHelpers';
export type { RequestHandler } from './util/util';
export * from './handlers/proxyRequests.js';
export * from './util/responseHelpers.js';
export type { RequestHandler } from './util/util.js';

View File

@@ -47,7 +47,7 @@ export function populateGeneralErrorResponse(res: ServerResponse, error: Discord
*/
export function populateRatelimitErrorResponse(res: ServerResponse, error: RateLimitError): void {
res.statusCode = 429;
res.setHeader('Retry-After', error.timeToReset / 1000);
res.setHeader('Retry-After', error.timeToReset / 1_000);
}
/**

View File

@@ -3,7 +3,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
/**
* Represents a potentially awaitable value
*/
export type Awaitable<T> = T | PromiseLike<T>;
export type Awaitable<T> = PromiseLike<T> | T;
/**
* Represents a simple HTTP request handler