mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
refactor: use eslint-config-neon for packages. (#8579)
Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { createServer } from 'node:http';
|
||||
import { REST } from '@discordjs/rest';
|
||||
import supertest from 'supertest';
|
||||
import { MockAgent, Interceptable, setGlobalDispatcher } from 'undici';
|
||||
import { MockAgent, setGlobalDispatcher, type Interceptable } from 'undici';
|
||||
import type { MockInterceptor } from 'undici/types/mock-interceptor';
|
||||
import { beforeEach, afterAll, afterEach, test, expect } from 'vitest';
|
||||
import { proxyRequests } from '../src';
|
||||
import { proxyRequests } from '../src/index.js';
|
||||
|
||||
let mockAgent: MockAgent;
|
||||
let mockPool: Interceptable;
|
||||
|
||||
@@ -64,15 +64,10 @@
|
||||
"@microsoft/api-extractor": "^7.29.5",
|
||||
"@types/node": "^16.11.56",
|
||||
"@types/supertest": "^2.0.12",
|
||||
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
||||
"@typescript-eslint/parser": "^5.36.1",
|
||||
"@vitest/coverage-c8": "^0.22.1",
|
||||
"downlevel-dts": "^0.10.1",
|
||||
"eslint": "^8.23.0",
|
||||
"eslint-config-marine": "^9.4.1",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-config-neon": "^0.1.23",
|
||||
"prettier": "^2.7.1",
|
||||
"rollup-plugin-typescript2": "^0.33.0",
|
||||
"supertest": "^6.2.4",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user