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,15 +1,16 @@
/* eslint-disable @typescript-eslint/consistent-type-imports */
import { REST } from '@discordjs/rest';
import { MockAgent, Interceptable } from 'undici';
import { MockAgent, type Interceptable } from 'undici';
import { beforeEach, test, vi, expect } from 'vitest';
import {
managerToFetchingStrategyOptions,
WorkerContextFetchingStrategy,
WorkerRecievePayload,
WorkerSendPayload,
WebSocketManager,
WorkerSendPayloadOp,
WorkerRecievePayloadOp,
} from '../../src';
type WorkerRecievePayload,
type WorkerSendPayload,
} from '../../src/index.js';
let mockAgent: MockAgent;
let mockPool: Interceptable;

View File

@@ -1,22 +1,24 @@
/* eslint-disable id-length */
import { setImmediate } from 'node:timers';
import { REST } from '@discordjs/rest';
import {
GatewayDispatchEvents,
GatewayDispatchPayload,
GatewayOpcodes,
GatewaySendPayload,
type GatewayDispatchPayload,
type GatewaySendPayload,
} from 'discord-api-types/v10';
import { MockAgent, Interceptable } from 'undici';
import { MockAgent, type Interceptable } from 'undici';
import { beforeEach, test, vi, expect, afterEach } from 'vitest';
import {
WorkerRecievePayload,
WorkerSendPayload,
WebSocketManager,
WorkerSendPayloadOp,
WorkerRecievePayloadOp,
WorkerShardingStrategy,
WebSocketShardEvents,
SessionInfo,
} from '../../src';
type WorkerRecievePayload,
type WorkerSendPayload,
type SessionInfo,
} from '../../src/index.js';
let mockAgent: MockAgent;
let mockPool: Interceptable;
@@ -43,6 +45,7 @@ const sessionInfo: SessionInfo = {
};
vi.mock('node:worker_threads', async () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
const { EventEmitter }: typeof import('node:events') = await vi.importActual('node:events');
class MockWorker extends EventEmitter {
public constructor(...args: any[]) {
@@ -54,6 +57,7 @@ vi.mock('node:worker_threads', async () => {
}
public postMessage(message: WorkerSendPayload) {
// eslint-disable-next-line default-case
switch (message.op) {
case WorkerSendPayloadOp.Connect: {
const response: WorkerRecievePayload = {

View File

@@ -1,6 +1,6 @@
import { setTimeout as sleep } from 'node:timers/promises';
import { expect, Mock, test, vi } from 'vitest';
import { IdentifyThrottler, WebSocketManager } from '../../src';
import { expect, test, vi, type Mock } from 'vitest';
import { IdentifyThrottler, type WebSocketManager } from '../../src/index.js';
vi.mock('node:timers/promises', () => ({
setTimeout: vi.fn(),

View File

@@ -1,8 +1,8 @@
import { REST } from '@discordjs/rest';
import { APIGatewayBotInfo, GatewayOpcodes, GatewaySendPayload } from 'discord-api-types/v10';
import { MockAgent, Interceptable } from 'undici';
import { GatewayOpcodes, type APIGatewayBotInfo, type GatewaySendPayload } from 'discord-api-types/v10';
import { MockAgent, type Interceptable } from 'undici';
import { beforeEach, describe, expect, test, vi } from 'vitest';
import { IShardingStrategy, WebSocketManager } from '../../src';
import { WebSocketManager, type IShardingStrategy } from '../../src/index.js';
vi.useFakeTimers();
@@ -80,7 +80,7 @@ test('fetch gateway information', async () => {
})
.reply(fetch);
NOW.mockReturnValue(Infinity);
NOW.mockReturnValue(Number.POSITIVE_INFINITY);
const cacheExpired = await manager.fetchGatewayInformation();
expect(cacheExpired).toEqual(data);
expect(fetch).toHaveBeenCalledOnce();
@@ -171,8 +171,11 @@ test('it handles passing in both shardIds and shardCount', async () => {
test('strategies', async () => {
class MockStrategy implements IShardingStrategy {
public spawn = vi.fn();
public connect = vi.fn();
public destroy = vi.fn();
public send = vi.fn();
}
@@ -219,6 +222,7 @@ test('strategies', async () => {
await manager.destroy(destroyOptions);
expect(strategy.destroy).toHaveBeenCalledWith(destroyOptions);
// eslint-disable-next-line id-length
const send: GatewaySendPayload = { op: GatewayOpcodes.RequestGuildMembers, d: { guild_id: '1234', limit: 0 } };
await manager.send(0, send);
expect(strategy.send).toHaveBeenCalledWith(0, send);