Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Commit 53c0cce

Browse files
committed
fix(Rest): lint errors
1 parent adb5302 commit 53c0cce

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

packages/rest/__tests__/REST.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ test('Request and Response Events', async () => {
225225
route: '/request',
226226
data: { attachments: undefined, body: undefined },
227227
retries: 0,
228-
}),
228+
}) as APIRequest,
229229
);
230230
expect(responseListener).toHaveBeenLastCalledWith<[APIRequest, Response]>(
231231
expect.objectContaining({
@@ -234,8 +234,8 @@ test('Request and Response Events', async () => {
234234
route: '/request',
235235
data: { attachments: undefined, body: undefined },
236236
retries: 0,
237-
}),
238-
expect.objectContaining({ status: 200, statusText: 'OK' }),
237+
}) as APIRequest,
238+
expect.objectContaining({ status: 200, statusText: 'OK' }) as Response,
239239
);
240240

241241
api.off('request', requestListener);

packages/rest/__tests__/RequestHandler.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
7575
})
7676
.get('/regularRequest')
7777
.reply(204, { test: true })
78-
.patch('/channels/:id', (body) => ['name', 'topic'].some((key) => Reflect.has(body, key)))
78+
.patch('/channels/:id', (body) => ['name', 'topic'].some((key) => Reflect.has(body as Record<string, unknown>, key)))
7979
.reply(function handler(): nock.ReplyFnResult {
8080
sublimitHits += 1;
8181
sublimitRequests += 1;
@@ -110,7 +110,9 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
110110
},
111111
];
112112
})
113-
.patch('/channels/:id', (body) => ['name', 'topic'].every((key) => !Reflect.has(body, key)))
113+
.patch('/channels/:id', (body) =>
114+
['name', 'topic'].every((key) => !Reflect.has(body as Record<string, unknown>, key)),
115+
)
114116
.reply(function handler(): nock.ReplyFnResult {
115117
sublimitRequests += 1;
116118
const response = 10 - sublimitRequests >= 0 ? 204 : 429;

packages/rest/src/lib/RequestManager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ export class RequestManager extends EventEmitter {
281281
// eslint-disable-next-line no-eq-null
282282
if (request.body != null) {
283283
if (request.appendToFormData) {
284-
for (const [key, value] of Object.entries(request.body as any)) formData.append(key, value);
284+
for (const [key, value] of Object.entries(request.body as Record<string, unknown>)) {
285+
formData.append(key, value);
286+
}
285287
} else {
286288
formData.append('payload_json', JSON.stringify(request.body));
287289
}

packages/rest/src/lib/errors/DiscordAPIError.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ export interface RequestBody {
2222
json: unknown | undefined;
2323
}
2424

25-
function isErrorGroupWrapper(error: any): error is DiscordErrorGroupWrapper {
26-
return Reflect.has(error, '_errors');
25+
function isErrorGroupWrapper(error: DiscordError): error is DiscordErrorGroupWrapper {
26+
return Reflect.has(error as Record<string, unknown>, '_errors');
2727
}
2828

29-
function isErrorResponse(error: any): error is DiscordErrorFieldInformation {
30-
return typeof Reflect.get(error, 'message') === 'string';
29+
function isErrorResponse(error: DiscordError): error is DiscordErrorFieldInformation {
30+
return typeof Reflect.get(error as Record<string, unknown>, 'message') === 'string';
3131
}
3232

3333
/**
@@ -85,11 +85,13 @@ export class DiscordAPIError extends Error {
8585

8686
if (typeof v === 'string') {
8787
yield v;
88+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
8889
} else if (isErrorGroupWrapper(v)) {
8990
for (const error of v._errors) {
9091
yield* this.flattenDiscordError(error, nextKey);
9192
}
9293
} else {
94+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
9395
yield* this.flattenDiscordError(v, nextKey);
9496
}
9597
}

0 commit comments

Comments
 (0)