From 3b7ba4062e7fbdc31242f20e2756b49e0af0b56e Mon Sep 17 00:00:00 2001 From: iCrawl Date: Thu, 1 Sep 2022 21:26:09 +0200 Subject: [PATCH] chore: fix leftover eslint exceptions --- build.config.ts | 19 +++---- .../src/ApiNodeJSONEncoder.ts | 5 +- .../src/tsdoc/CommentNode.ts | 14 ++--- .../__tests__/components/button.test.ts | 6 +-- .../__tests__/components/selectMenu.test.ts | 22 ++++---- .../__tests__/components/textInput.test.ts | 2 +- .../interactions/ContextMenuCommands.test.ts | 4 +- .../SlashCommands/Options.test.ts | 9 ++-- .../SlashCommands/SlashCommands.test.ts | 45 ++++++++-------- .../__tests__/interactions/modal.test.ts | 4 +- .../builders/__tests__/messages/embed.test.ts | 4 +- packages/builders/src/components/ActionRow.ts | 7 ++- .../builders/src/components/Components.ts | 1 - .../builders/src/components/button/Button.ts | 2 +- .../src/components/selectMenu/SelectMenu.ts | 2 +- .../components/selectMenu/SelectMenuOption.ts | 2 +- .../src/components/textInput/TextInput.ts | 2 +- .../contextMenuCommands/Assertions.ts | 2 +- .../builders/src/interactions/modals/Modal.ts | 2 +- .../interactions/slashCommands/Assertions.ts | 6 +-- .../slashCommands/SlashCommandSubcommands.ts | 2 +- packages/builders/src/messages/formatters.ts | 2 - .../collection/__tests__/collection.test.ts | 53 +++++++++---------- packages/collection/src/collection.ts | 7 --- packages/docgen/src/documentation.ts | 4 -- packages/docgen/src/index.ts | 4 +- packages/docgen/src/types/class.ts | 7 +-- packages/docgen/src/types/constructor.ts | 4 +- packages/docgen/src/types/event.ts | 9 +--- packages/docgen/src/types/member.ts | 16 ++---- packages/docgen/src/types/method.ts | 11 +--- packages/docgen/src/types/param.ts | 3 +- packages/docgen/src/types/typedef.ts | 23 +++----- packages/docgen/src/util/parseType.ts | 1 - packages/docgen/src/util/types.ts | 1 - packages/proxy-container/src/index.ts | 1 - .../proxy/__tests__/proxyRequests.test.ts | 1 - .../rest/__tests__/RequestHandler.test.ts | 2 - packages/rest/__tests__/Util.test.ts | 4 +- packages/rest/src/lib/REST.ts | 2 +- packages/rest/src/lib/RequestManager.ts | 7 +-- .../rest/src/lib/errors/DiscordAPIError.ts | 2 - packages/rest/src/lib/handlers/IHandler.ts | 1 - .../src/lib/handlers/SequentialHandler.ts | 4 -- packages/rest/src/lib/utils/constants.ts | 3 +- packages/rest/src/lib/utils/utils.ts | 2 - packages/voice/__tests__/AudioPlayer.test.ts | 5 +- .../voice/__tests__/AudioResource.test.ts | 5 +- packages/voice/__tests__/DataStore.test.ts | 1 - packages/voice/__tests__/SSRCMap.test.ts | 4 +- .../voice/__tests__/VoiceConnection.test.ts | 6 +-- .../voice/__tests__/VoiceReceiver.test.ts | 2 - .../voice/__tests__/VoiceUDPSocket.test.ts | 5 +- .../voice/__tests__/VoiceWebSocket.test.ts | 3 -- packages/voice/__tests__/demuxProbe.test.ts | 9 +--- packages/voice/__tests__/entersState.test.ts | 6 +-- .../voice/__tests__/joinVoiceChannel.test.ts | 1 - packages/voice/examples/recorder/src/bot.ts | 1 - packages/voice/src/DataStore.ts | 2 +- packages/voice/src/VoiceConnection.ts | 2 - packages/voice/src/audio/AudioPlayer.ts | 4 +- packages/voice/src/networking/Networking.ts | 13 ----- .../voice/src/networking/VoiceWebSocket.ts | 3 -- .../voice/src/receive/AudioReceiveStream.ts | 1 - packages/voice/src/receive/VoiceReceiver.ts | 12 ----- packages/voice/src/util/Secretbox.ts | 19 +------ packages/voice/src/util/abortAfter.ts | 1 - .../src/util/generateDependencyReport.ts | 5 -- packages/voice/src/util/util.ts | 1 - .../website/src/components/SidebarItems.tsx | 1 - .../src/components/TableOfContentItems.tsx | 1 - packages/website/src/pages/docs/[...slug].tsx | 5 -- .../pages/docs/packages/[package]/index.tsx | 1 - packages/website/src/util/api-model.server.ts | 4 -- .../strategy/WorkerShardingStrategy.test.ts | 3 -- .../context/WorkerContextFetchingStrategy.ts | 3 +- .../sharding/WorkerShardingStrategy.ts | 8 +-- packages/ws/src/strategies/sharding/worker.ts | 2 - packages/ws/src/utils/constants.ts | 2 - packages/ws/src/ws/WebSocketShard.ts | 1 - 80 files changed, 141 insertions(+), 337 deletions(-) diff --git a/build.config.ts b/build.config.ts index c598305f9..5c1d24f86 100644 --- a/build.config.ts +++ b/build.config.ts @@ -2,18 +2,18 @@ import { relative, resolve } from 'node:path'; import glob from 'fast-glob'; import isCi from 'is-ci'; import typescript from 'rollup-plugin-typescript2'; -import { defineBuildConfig, BuildEntry } from 'unbuild'; +import { defineBuildConfig, type BuildEntry } from 'unbuild'; interface ConfigOptions { - entries: (BuildEntry | string)[]; - minify: boolean; - emitCJS: boolean; - externals: string[]; cjsBridge: boolean; - sourcemap: boolean; + declaration: boolean; + emitCJS: boolean; + entries: (BuildEntry | string)[]; + externals: string[]; + minify: boolean; preserveModules: boolean; preserveModulesRoot: string; - declaration: boolean; + sourcemap: boolean; typeCheck: boolean; } @@ -31,8 +31,7 @@ export function createUnbuildConfig({ }: Partial = {}) { const files = glob .sync('**', { cwd: 'src' }) - .map((file) => [`${file.slice(0, -2)}cjs`, `${file.slice(0, -2)}mjs`]) - .flat(); + .flatMap((file) => [`${file.slice(0, -2)}cjs`, `${file.slice(0, -2)}mjs`]); return defineBuildConfig({ entries, @@ -55,7 +54,6 @@ export function createUnbuildConfig({ hooks: { 'rollup:options': (_, options) => { // @ts-expect-error: This will always be an array - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment options.output![0] = { // @ts-expect-error: This will always be an array ...options.output![0], @@ -66,7 +64,6 @@ export function createUnbuildConfig({ if (emitCJS) { // @ts-expect-error: This will always be an array - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment options.output![1] = { // @ts-expect-error: This will always be an array ...options.output![1], diff --git a/packages/api-extractor-utils/src/ApiNodeJSONEncoder.ts b/packages/api-extractor-utils/src/ApiNodeJSONEncoder.ts index 8952b4116..4cc773cbc 100644 --- a/packages/api-extractor-utils/src/ApiNodeJSONEncoder.ts +++ b/packages/api-extractor-utils/src/ApiNodeJSONEncoder.ts @@ -20,8 +20,8 @@ import { } from '@microsoft/api-extractor-model'; import { generateTypeParamData } from './TypeParameterJSONEncoder.js'; import { type TokenDocumentation, resolveName, genReference, genToken, genParameter, generatePath } from './parse.js'; -import type { DocBlockJSON } from './tsdoc/CommentBlock'; -import type { AnyDocNodeJSON } from './tsdoc/CommentNode'; +import type { DocBlockJSON } from './tsdoc/CommentBlock.js'; +import type { AnyDocNodeJSON } from './tsdoc/CommentNode.js'; import { type DocNodeContainerJSON, nodeContainer } from './tsdoc/CommentNodeContainer.js'; import { createCommentNode } from './tsdoc/index.js'; @@ -140,7 +140,6 @@ export interface ApiConstructorJSON extends ApiItemJSON, ApiParameterListJSON { protected: boolean; } -// eslint-disable-next-line @typescript-eslint/no-extraneous-class export class ApiNodeJSONEncoder { public static encode(model: ApiModel, node: ApiItem, version: string) { if (!(node instanceof ApiDeclaredItem)) { diff --git a/packages/api-extractor-utils/src/tsdoc/CommentNode.ts b/packages/api-extractor-utils/src/tsdoc/CommentNode.ts index 5542a6baf..078b1c652 100644 --- a/packages/api-extractor-utils/src/tsdoc/CommentNode.ts +++ b/packages/api-extractor-utils/src/tsdoc/CommentNode.ts @@ -1,11 +1,11 @@ import type { DocNode, DocNodeKind } from '@microsoft/tsdoc'; -import type { DocBlockJSON } from './CommentBlock'; -import type { DocCodeSpanJSON } from './CommentCodeSpan'; -import type { DocNodeContainerJSON } from './CommentNodeContainer'; -import type { DocFencedCodeJSON } from './FencedCodeCommentNode'; -import type { DocLinkTagJSON } from './LinkTagCommentNode'; -import type { DocPlainTextJSON } from './PlainTextCommentNode'; -import type { DocCommentJSON } from './RootComment'; +import type { DocBlockJSON } from './CommentBlock.js'; +import type { DocCodeSpanJSON } from './CommentCodeSpan.js'; +import type { DocNodeContainerJSON } from './CommentNodeContainer.js'; +import type { DocFencedCodeJSON } from './FencedCodeCommentNode.js'; +import type { DocLinkTagJSON } from './LinkTagCommentNode.js'; +import type { DocPlainTextJSON } from './PlainTextCommentNode.js'; +import type { DocCommentJSON } from './RootComment.js'; export interface DocNodeJSON { kind: DocNodeKind; diff --git a/packages/builders/__tests__/components/button.test.ts b/packages/builders/__tests__/components/button.test.ts index 11f34a3cb..ca7156fd1 100644 --- a/packages/builders/__tests__/components/button.test.ts +++ b/packages/builders/__tests__/components/button.test.ts @@ -71,7 +71,7 @@ describe('Button Components', () => { }).toThrowError(); expect(() => { - // @ts-expect-error: invalid emoji + // @ts-expect-error: Invalid emoji const button = buttonComponent().setEmoji('test'); button.toJSON(); }).toThrowError(); @@ -103,9 +103,9 @@ describe('Button Components', () => { expect(() => buttonComponent().setStyle(24)).toThrowError(); expect(() => buttonComponent().setLabel(longStr)).toThrowError(); - // @ts-expect-error: invalid parameter for disabled + // @ts-expect-error: Invalid parameter for disabled expect(() => buttonComponent().setDisabled(0)).toThrowError(); - // @ts-expect-error: invalid emoji + // @ts-expect-error: Invalid emoji expect(() => buttonComponent().setEmoji('foo')).toThrowError(); expect(() => buttonComponent().setURL('foobar')).toThrowError(); diff --git a/packages/builders/__tests__/components/selectMenu.test.ts b/packages/builders/__tests__/components/selectMenu.test.ts index 39a6c0e11..c5e10c53c 100644 --- a/packages/builders/__tests__/components/selectMenu.test.ts +++ b/packages/builders/__tests__/components/selectMenu.test.ts @@ -98,30 +98,30 @@ describe('Select Menu Components', () => { expect(() => selectMenu().setCustomId(longStr)).toThrowError(); expect(() => selectMenu().setMaxValues(30)).toThrowError(); expect(() => selectMenu().setMinValues(-20)).toThrowError(); - // @ts-expect-error: invalid disabled value + // @ts-expect-error: Invalid disabled value expect(() => selectMenu().setDisabled(0)).toThrowError(); expect(() => selectMenu().setPlaceholder(longStr)).toThrowError(); - // @ts-expect-error: invalid option + // @ts-expect-error: Invalid option expect(() => selectMenu().addOptions({ label: 'test' })).toThrowError(); expect(() => selectMenu().addOptions({ label: longStr, value: 'test' })).toThrowError(); expect(() => selectMenu().addOptions({ value: longStr, label: 'test' })).toThrowError(); expect(() => selectMenu().addOptions({ label: 'test', value: 'test', description: longStr })).toThrowError(); - // @ts-expect-error: invalid option + // @ts-expect-error: Invalid option expect(() => selectMenu().addOptions({ label: 'test', value: 'test', default: 100 })).toThrowError(); - // @ts-expect-error: invalid option + // @ts-expect-error: Invalid option expect(() => selectMenu().addOptions({ value: 'test' })).toThrowError(); - // @ts-expect-error: invalid option + // @ts-expect-error: Invalid option expect(() => selectMenu().addOptions({ default: true })).toThrowError(); - // @ts-expect-error: invalid option + // @ts-expect-error: Invalid option expect(() => selectMenu().addOptions([{ label: 'test' }])).toThrowError(); expect(() => selectMenu().addOptions([{ label: longStr, value: 'test' }])).toThrowError(); expect(() => selectMenu().addOptions([{ value: longStr, label: 'test' }])).toThrowError(); expect(() => selectMenu().addOptions([{ label: 'test', value: 'test', description: longStr }])).toThrowError(); - // @ts-expect-error: invalid option + // @ts-expect-error: Invalid option expect(() => selectMenu().addOptions([{ label: 'test', value: 'test', default: 100 }])).toThrowError(); - // @ts-expect-error: invalid option + // @ts-expect-error: Invalid option expect(() => selectMenu().addOptions([{ value: 'test' }])).toThrowError(); - // @ts-expect-error: invalid option + // @ts-expect-error: Invalid option expect(() => selectMenu().addOptions([{ default: true }])).toThrowError(); const tooManyOptions = Array.from({ length: 26 }).fill({ label: 'test', value: 'test' }); @@ -144,9 +144,9 @@ describe('Select Menu Components', () => { selectMenuOption() .setLabel(longStr) .setValue(longStr) - // @ts-expect-error: invalid default value + // @ts-expect-error: Invalid default value .setDefault(-1) - // @ts-expect-error: invalid emoji + // @ts-expect-error: Invalid emoji .setEmoji({ name: 1 }) .setDescription(longStr); }).toThrowError(); diff --git a/packages/builders/__tests__/components/textInput.test.ts b/packages/builders/__tests__/components/textInput.test.ts index 62b0085f6..ab09ffe00 100644 --- a/packages/builders/__tests__/components/textInput.test.ts +++ b/packages/builders/__tests__/components/textInput.test.ts @@ -85,7 +85,7 @@ describe('Text Input Components', () => { expect(() => { // Issue #8107 - // @ts-expect-error: shapeshift maps the enum key to the value when parsing + // @ts-expect-error: Shapeshift maps the enum key to the value when parsing textInputComponent().setCustomId('Custom').setLabel('Guess').setStyle('Short').toJSON(); }).not.toThrowError(); }); diff --git a/packages/builders/__tests__/interactions/ContextMenuCommands.test.ts b/packages/builders/__tests__/interactions/ContextMenuCommands.test.ts index d2cbe3802..99716c886 100644 --- a/packages/builders/__tests__/interactions/ContextMenuCommands.test.ts +++ b/packages/builders/__tests__/interactions/ContextMenuCommands.test.ts @@ -105,9 +105,9 @@ describe('Context Menu Commands', () => { }); test('GIVEN invalid name localizations THEN does throw error', () => { - // @ts-expect-error: invalid localization + // @ts-expect-error: Invalid localization expect(() => getBuilder().setNameLocalization('en-U', 'foobar')).toThrowError(); - // @ts-expect-error: invalid localization + // @ts-expect-error: Invalid localization expect(() => getBuilder().setNameLocalizations({ 'en-U': 'foobar' })).toThrowError(); }); diff --git a/packages/builders/__tests__/interactions/SlashCommands/Options.test.ts b/packages/builders/__tests__/interactions/SlashCommands/Options.test.ts index 25875bb67..257aba3f6 100644 --- a/packages/builders/__tests__/interactions/SlashCommands/Options.test.ts +++ b/packages/builders/__tests__/interactions/SlashCommands/Options.test.ts @@ -101,7 +101,8 @@ describe('Application Command toJSON() results', () => { max_value: 10, min_value: -1, autocomplete: true, - // @ts-expect-error TODO: you *can* send an empty array with autocomplete: true, should correct that in types + // TODO + // @ts-expect-error You *can* send an empty array with autocomplete: true, should correct that in types choices: [], }); @@ -145,7 +146,8 @@ describe('Application Command toJSON() results', () => { max_value: 10, min_value: -1.23, autocomplete: true, - // @ts-expect-error TODO: you *can* send an empty array with autocomplete: true, should correct that in types + // TODO + // @ts-expect-error You *can* send an empty array with autocomplete: true, should correct that in types choices: [], }); @@ -187,7 +189,8 @@ describe('Application Command toJSON() results', () => { type: ApplicationCommandOptionType.String, required: true, autocomplete: true, - // @ts-expect-error TODO: you *can* send an empty array with autocomplete: true, should correct that in types + // TODO + // @ts-expect-error you *can* send an empty array with autocomplete: true, should correct that in types choices: [], }); diff --git a/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts b/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts index ef03954d5..863dc61b1 100644 --- a/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts +++ b/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts @@ -176,7 +176,7 @@ describe('Slash Commands', () => { }); test('GIVEN a builder with invalid autocomplete THEN does throw an error', () => { - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addStringOption(getStringOption().setAutocomplete('not a boolean'))).toThrowError(); }); @@ -246,16 +246,16 @@ describe('Slash Commands', () => { }); test('GIVEN a builder with invalid number min/max options THEN does throw an error', () => { - // @ts-expect-error: invalid max value + // @ts-expect-error: Invalid max value expect(() => getBuilder().addNumberOption(getNumberOption().setMaxValue('test'))).toThrowError(); - // @ts-expect-error: invalid max value + // @ts-expect-error: Invalid max value expect(() => getBuilder().addIntegerOption(getIntegerOption().setMaxValue('test'))).toThrowError(); - // @ts-expect-error: invalid min value + // @ts-expect-error: Invalid min value expect(() => getBuilder().addNumberOption(getNumberOption().setMinValue('test'))).toThrowError(); - // @ts-expect-error: invalid min value + // @ts-expect-error: Invalid min value expect(() => getBuilder().addIntegerOption(getIntegerOption().setMinValue('test'))).toThrowError(); expect(() => getBuilder().addIntegerOption(getIntegerOption().setMinValue(1.5))).toThrowError(); @@ -292,10 +292,10 @@ describe('Slash Commands', () => { }); test('GIVEN no valid return for an addOption method THEN throw error', () => { - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addBooleanOption()).toThrowError(); - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addBooleanOption(getRoleOption())).toThrowError(); }); @@ -316,18 +316,18 @@ describe('Slash Commands', () => { }); test('GIVEN invalid returns for builder THEN throw error', () => { - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addBooleanOption(true)).toThrowError(); - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addBooleanOption(null)).toThrowError(); - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addBooleanOption(undefined)).toThrowError(); - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addBooleanOption(() => SlashCommandStringOption)).toThrowError(); - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addBooleanOption(() => new Collection())).toThrowError(); }); @@ -387,30 +387,29 @@ describe('Slash Commands', () => { test('GIVEN builder with a subcommand that tries to add an invalid result THEN throw error', () => { expect(() => - // @ts-expect-error Checking if check works JS-side too - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call + // @ts-expect-error: Checking if check works JS-side too getNamedBuilder().addSubcommand(getSubcommand()).addInteger(getInteger()), ).toThrowError(); }); test('GIVEN no valid return for an addSubcommand(Group) method THEN throw error', () => { - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addSubcommandGroup()).toThrowError(); - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addSubcommand()).toThrowError(); - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getBuilder().addSubcommand(getSubcommandGroup())).toThrowError(); }); }); describe('Subcommand group builder', () => { test('GIVEN no valid subcommand THEN throw error', () => { - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getSubcommandGroup().addSubcommand()).toThrowError(); - // @ts-expect-error Checking if not providing anything, or an invalid return type causes an error + // @ts-expect-error: Checking if not providing anything, or an invalid return type causes an error expect(() => getSubcommandGroup().addSubcommand(getSubcommandGroup())).toThrowError(); }); @@ -442,9 +441,9 @@ describe('Slash Commands', () => { }); test('GIVEN invalid name localizations THEN does throw error', () => { - // @ts-expect-error: invalid localization + // @ts-expect-error: Invalid localization expect(() => getBuilder().setNameLocalization('en-U', 'foobar')).toThrowError(); - // @ts-expect-error: invalid localization + // @ts-expect-error: Invalid localization expect(() => getBuilder().setNameLocalizations({ 'en-U': 'foobar' })).toThrowError(); }); @@ -465,9 +464,9 @@ describe('Slash Commands', () => { }); test('GIVEN invalid description localizations THEN does throw error', () => { - // @ts-expect-error: invalid localization description + // @ts-expect-error: Invalid localization description expect(() => getBuilder().setDescriptionLocalization('en-U', 'foobar')).toThrowError(); - // @ts-expect-error: invalid localization description + // @ts-expect-error: Invalid localization description expect(() => getBuilder().setDescriptionLocalizations({ 'en-U': 'foobar' })).toThrowError(); }); diff --git a/packages/builders/__tests__/interactions/modal.test.ts b/packages/builders/__tests__/interactions/modal.test.ts index 3eaa934ad..17bdfefb4 100644 --- a/packages/builders/__tests__/interactions/modal.test.ts +++ b/packages/builders/__tests__/interactions/modal.test.ts @@ -46,7 +46,7 @@ describe('Modals', () => { test('GIVEN invalid required parameters THEN validator does throw', () => { expect(() => - // @ts-expect-error: missing required parameter + // @ts-expect-error: Missing required parameter validateRequiredParameters('123', undefined, [new ActionRowBuilder(), new ButtonBuilder()]), ).toThrowError(); }); @@ -66,7 +66,7 @@ describe('Modals', () => { test('GIVEN invalid fields THEN builder does throw', () => { expect(() => modal().setTitle('test').setCustomId('foobar').toJSON()).toThrowError(); - // @ts-expect-error: customId is invalid + // @ts-expect-error: CustomId is invalid expect(() => modal().setTitle('test').setCustomId(42).toJSON()).toThrowError(); }); diff --git a/packages/builders/__tests__/messages/embed.test.ts b/packages/builders/__tests__/messages/embed.test.ts index 0c33255bf..3a0ef2702 100644 --- a/packages/builders/__tests__/messages/embed.test.ts +++ b/packages/builders/__tests__/messages/embed.test.ts @@ -130,9 +130,9 @@ describe('Embed', () => { test('GIVEN an embed with an invalid color THEN throws error', () => { const embed = new EmbedBuilder(); - // @ts-expect-error: invalid color + // @ts-expect-error: Invalid color expect(() => embed.setColor('RED')).toThrowError(); - // @ts-expect-error: invalid color + // @ts-expect-error: Invalid color expect(() => embed.setColor([42, 36])).toThrowError(); expect(() => embed.setColor([42, 36, 1_000])).toThrowError(); }); diff --git a/packages/builders/src/components/ActionRow.ts b/packages/builders/src/components/ActionRow.ts index 3a74a21c7..e328e4664 100644 --- a/packages/builders/src/components/ActionRow.ts +++ b/packages/builders/src/components/ActionRow.ts @@ -8,9 +8,9 @@ import { import { normalizeArray, type RestOrArray } from '../util/normalizeArray.js'; import { ComponentBuilder } from './Component.js'; import { createComponentBuilder } from './Components.js'; -import type { ButtonBuilder } from './button/Button'; -import type { SelectMenuBuilder } from './selectMenu/SelectMenu'; -import type { TextInputBuilder } from './textInput/TextInput'; +import type { ButtonBuilder } from './button/Button.js'; +import type { SelectMenuBuilder } from './selectMenu/SelectMenu.js'; +import type { TextInputBuilder } from './textInput/TextInput.js'; export type MessageComponentBuilder = | ActionRowBuilder @@ -62,7 +62,6 @@ export class ActionRowBuilder extends ComponentBu * {@inheritDoc ComponentBuilder.toJSON} */ public toJSON(): APIActionRowComponent> { - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions return { ...this.data, components: this.components.map((component) => component.toJSON()), diff --git a/packages/builders/src/components/Components.ts b/packages/builders/src/components/Components.ts index 4c73932f7..ea13e013d 100644 --- a/packages/builders/src/components/Components.ts +++ b/packages/builders/src/components/Components.ts @@ -45,7 +45,6 @@ export function createComponentBuilder( return new TextInputBuilder(data); default: // @ts-expect-error: This case can still occur if we get a newer unsupported component type - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions throw new Error(`Cannot properly serialize component type: ${data.type}`); } } diff --git a/packages/builders/src/components/button/Button.ts b/packages/builders/src/components/button/Button.ts index 4b63002fb..7f05c636a 100644 --- a/packages/builders/src/components/button/Button.ts +++ b/packages/builders/src/components/button/Button.ts @@ -129,7 +129,7 @@ export class ButtonBuilder extends ComponentBuilder { (this.data as APIButtonComponentWithCustomId).custom_id, (this.data as APIButtonComponentWithURL).url, ); - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + return { ...this.data, } as APIButtonComponent; diff --git a/packages/builders/src/components/selectMenu/SelectMenu.ts b/packages/builders/src/components/selectMenu/SelectMenu.ts index 39fdfb6d6..a3806ad3a 100644 --- a/packages/builders/src/components/selectMenu/SelectMenu.ts +++ b/packages/builders/src/components/selectMenu/SelectMenu.ts @@ -123,7 +123,7 @@ export class SelectMenuBuilder extends ComponentBuilder */ public toJSON(): APISelectMenuComponent { validateRequiredSelectMenuParameters(this.options, this.data.custom_id); - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + return { ...this.data, options: this.options.map((option) => option.toJSON()), diff --git a/packages/builders/src/components/selectMenu/SelectMenuOption.ts b/packages/builders/src/components/selectMenu/SelectMenuOption.ts index 26edf23dc..2529eeff2 100644 --- a/packages/builders/src/components/selectMenu/SelectMenuOption.ts +++ b/packages/builders/src/components/selectMenu/SelectMenuOption.ts @@ -68,7 +68,7 @@ export class SelectMenuOptionBuilder implements JSONEncodable component.toJSON()), diff --git a/packages/builders/src/interactions/slashCommands/Assertions.ts b/packages/builders/src/interactions/slashCommands/Assertions.ts index 7a251a616..586f968a1 100644 --- a/packages/builders/src/interactions/slashCommands/Assertions.ts +++ b/packages/builders/src/interactions/slashCommands/Assertions.ts @@ -1,9 +1,9 @@ import { s } from '@sapphire/shapeshift'; import { Locale, type APIApplicationCommandOptionChoice, type LocalizationMap } from 'discord-api-types/v10'; import { isValidationEnabled } from '../../util/validation.js'; -import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder'; -import type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands'; -import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase'; +import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder.js'; +import type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands.js'; +import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase.js'; const namePredicate = s.string .lengthGreaterThanOrEqual(1) diff --git a/packages/builders/src/interactions/slashCommands/SlashCommandSubcommands.ts b/packages/builders/src/interactions/slashCommands/SlashCommandSubcommands.ts index 22550b263..e9b540448 100644 --- a/packages/builders/src/interactions/slashCommands/SlashCommandSubcommands.ts +++ b/packages/builders/src/interactions/slashCommands/SlashCommandSubcommands.ts @@ -6,7 +6,7 @@ import { import { mix } from 'ts-mixer'; import { assertReturnOfBuilder, validateMaxOptionsLength, validateRequiredParameters } from './Assertions.js'; import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder.js'; -import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase'; +import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase.js'; import { SharedNameAndDescription } from './mixins/NameAndDescription.js'; import { SharedSlashCommandOptions } from './mixins/SharedSlashCommandOptions.js'; diff --git a/packages/builders/src/messages/formatters.ts b/packages/builders/src/messages/formatters.ts index 9396d36cf..2bbd50dd7 100644 --- a/packages/builders/src/messages/formatters.ts +++ b/packages/builders/src/messages/formatters.ts @@ -96,7 +96,6 @@ export function hideLinkEmbed(url: C): `<${C}>`; */ export function hideLinkEmbed(url: URL): `<${string}>`; export function hideLinkEmbed(url: URL | string) { - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions return `<${url}>`; } @@ -142,7 +141,6 @@ export function hyperlink( title: T, ): `[${C}](${U} "${T}")`; export function hyperlink(content: string, url: URL | string, title?: string) { - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`; } diff --git a/packages/collection/__tests__/collection.test.ts b/packages/collection/__tests__/collection.test.ts index 1ea89164f..b2d01213f 100644 --- a/packages/collection/__tests__/collection.test.ts +++ b/packages/collection/__tests__/collection.test.ts @@ -20,7 +20,6 @@ function createTestCollection(): TestCollection { function expectInvalidFunctionError(cb: () => unknown, val?: unknown): void { expect(() => { cb(); - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions }).toThrowError(new TypeError(`${val} is not a function`)); } @@ -133,9 +132,9 @@ describe('each() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.each()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.each(123), 123); }); @@ -154,7 +153,7 @@ describe('each() tests', () => { describe('ensure() tests', () => { test('throws if defaultValueGenerator is not a function', () => { const coll = createTestCollection(); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.ensure('d', 'abc'), 'abc'); }); @@ -178,7 +177,7 @@ describe('equals() tests', () => { const coll2 = createTestCollection(); test('returns false if no collection is passed', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expect(coll1.equals()).toBeFalsy(); }); @@ -200,9 +199,9 @@ describe('every() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.every()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.every(123), 123); }); @@ -226,9 +225,9 @@ describe('filter() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.filter()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.filter(123), 123); }); @@ -253,9 +252,9 @@ describe('find() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => createCollection().find()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => createCollection().find(123), 123); }); @@ -277,9 +276,9 @@ describe('findKey() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.findKey()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.findKey(123), 123); }); @@ -508,9 +507,9 @@ describe('map() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.map()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.map(123), 123); }); @@ -531,9 +530,9 @@ describe('mapValues() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.mapValues()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.mapValues(123), 123); }); @@ -608,9 +607,9 @@ describe('partition() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.partition()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.partition(123), 123); }); @@ -692,9 +691,9 @@ describe('reduce() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.reduce()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.reduce(123), 123); }); @@ -731,9 +730,9 @@ describe('some() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.some()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.some(123), 123); }); @@ -775,9 +774,9 @@ describe('sweep() test', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.sweep()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.sweep(123), 123); }); @@ -802,9 +801,9 @@ describe('tap() tests', () => { const coll = createTestCollection(); test('throws if fn is not a function', () => { - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.tap()); - // @ts-expect-error: invalid function + // @ts-expect-error: Invalid function expectInvalidFunctionError(() => coll.tap(123), 123); }); diff --git a/packages/collection/src/collection.ts b/packages/collection/src/collection.ts index edd837beb..4f67ddde2 100644 --- a/packages/collection/src/collection.ts +++ b/packages/collection/src/collection.ts @@ -85,12 +85,10 @@ export class Collection extends Map { public first(): V | undefined; public first(amount: number): V[]; public first(amount?: number): V | V[] | undefined { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return if (typeof amount === 'undefined') return this.values().next().value; if (amount < 0) return this.last(amount * -1); amount = Math.min(this.size, amount); const iter = this.values(); - // eslint-disable-next-line @typescript-eslint/no-unsafe-return return Array.from({ length: amount }, (): V => iter.next().value); } @@ -104,12 +102,10 @@ export class Collection extends Map { public firstKey(): K | undefined; public firstKey(amount: number): K[]; public firstKey(amount?: number): K | K[] | undefined { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return if (typeof amount === 'undefined') return this.keys().next().value; if (amount < 0) return this.lastKey(amount * -1); amount = Math.min(this.size, amount); const iter = this.keys(); - // eslint-disable-next-line @typescript-eslint/no-unsafe-return return Array.from({ length: amount }, (): K => iter.next().value); } @@ -426,9 +422,7 @@ export class Collection extends Map { if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg); const iter = this.entries(); return Array.from({ length: this.size }, (): T => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const [key, value] = iter.next().value; - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return fn(value, key, this); }); } @@ -636,7 +630,6 @@ export class Collection extends Map { * @returns Whether the collections have identical contents */ public equals(collection: ReadonlyCollection) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!collection) return false; // runtime check if (this === collection) return true; if (this.size !== collection.size) return false; diff --git a/packages/docgen/src/documentation.ts b/packages/docgen/src/documentation.ts index 7b4830064..2c27601fd 100644 --- a/packages/docgen/src/documentation.ts +++ b/packages/docgen/src/documentation.ts @@ -123,7 +123,6 @@ export class Documentation { case 'Method': { const event = prop?.groups?.find((group) => group.title === 'Events'); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if ((event?.children as unknown as number[])?.includes(member.id)) { item = new DocumentedEvent(member, this.config); break; @@ -139,7 +138,6 @@ export class Documentation { } default: { - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions console.warn(`- Unknown documentation kind "${member.kindString}" - \n${JSON.stringify(member)}\n`); } } @@ -212,7 +210,6 @@ export class Documentation { default: { // @ts-expect-error: This is a valid case - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions console.warn(`- Unknown documentation kind "${member.kind}" - \n${JSON.stringify(member)}\n`); } } @@ -233,7 +230,6 @@ export class Documentation { const info = []; const name = (member.name || item?.data.name) ?? 'UNKNOWN'; // @ts-expect-error: Typescript can't infer this - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unnecessary-condition const memberof = member.memberof ?? item?.data?.memberof; const meta = member.kind === 'constructor' diff --git a/packages/docgen/src/index.ts b/packages/docgen/src/index.ts index de35a5009..a301a9961 100644 --- a/packages/docgen/src/index.ts +++ b/packages/docgen/src/index.ts @@ -2,9 +2,9 @@ import { readFileSync, writeFileSync } from 'node:fs'; import { dirname, join, extname, basename, relative } from 'node:path'; import jsdoc2md from 'jsdoc-to-markdown'; import { type DeclarationReflection, Application, TSConfigReader } from 'typedoc'; -import type { CLIOptions } from './cli'; +import type { CLIOptions } from './cli.js'; import { Documentation } from './documentation.js'; -import type { RootTypes, ChildTypes, CustomDocs } from './interfaces'; +import type { RootTypes, ChildTypes, CustomDocs } from './interfaces/index.js'; interface CustomFiles { files: { diff --git a/packages/docgen/src/types/class.ts b/packages/docgen/src/types/class.ts index 0a2aa0eb8..ca2dbcb14 100644 --- a/packages/docgen/src/types/class.ts +++ b/packages/docgen/src/types/class.ts @@ -58,7 +58,6 @@ export class DocumentedClass extends DocumentedItem block.tag === '@see').length ? signature.comment.blockTags .filter((block) => block.tag === '@see') @@ -100,7 +98,6 @@ export class DocumentedClass extends DocumentedItem (prev += curr.text), '').trim() || undefined, @@ -109,13 +106,11 @@ export class DocumentedClass extends DocumentedItem block.tag === '@private' || block.tag === '@internal') ? 'private' : undefined, - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing abstract: signature.comment?.blockTags?.some((block) => block.tag === '@abstract') || undefined, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition deprecated: signature.comment?.blockTags?.some((block) => block.tag === '@deprecated') ? signature.comment.blockTags .find((block) => block.tag === '@deprecated') diff --git a/packages/docgen/src/types/constructor.ts b/packages/docgen/src/types/constructor.ts index c88ab68b1..e046cf6c5 100644 --- a/packages/docgen/src/types/constructor.ts +++ b/packages/docgen/src/types/constructor.ts @@ -9,7 +9,6 @@ export class DocumentedConstructor extends DocumentedItem block.tag === '@see').length ? signature.comment.blockTags .filter((block) => block.tag === '@see') @@ -18,12 +17,11 @@ export class DocumentedConstructor extends DocumentedItem (prev += curr.text), '').trim() || undefined, see, access: data.flags.isPrivate || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition signature.comment?.blockTags?.some((block) => block.tag === '@private' || block.tag === '@internal') ? 'private' : undefined, diff --git a/packages/docgen/src/types/event.ts b/packages/docgen/src/types/event.ts index 6af0b050e..a72db11b9 100644 --- a/packages/docgen/src/types/event.ts +++ b/packages/docgen/src/types/event.ts @@ -18,14 +18,12 @@ export class DocumentedEvent extends DocumentedItem block.tag === '@see').length ? signature.comment.blockTags .filter((block) => block.tag === '@see') .map((block) => block.content.find((contentText) => contentText.kind === 'text')?.text.trim()) : undefined; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition const examples = signature.comment?.blockTags?.filter((block) => block.tag === '@example').length ? signature.comment.blockTags .filter((block) => block.tag === '@example') @@ -35,19 +33,16 @@ export class DocumentedEvent extends DocumentedItem (prev += curr.text), '').trim() || undefined, see, access: data.flags.isPrivate || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition signature.comment?.blockTags?.some((block) => block.tag === '@private' || block.tag === '@internal') ? 'private' : undefined, examples, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition deprecated: signature.comment?.blockTags?.some((block) => block.tag === '@deprecated') ? signature.comment.blockTags .find((block) => block.tag === '@deprecated') @@ -68,7 +63,6 @@ export class DocumentedEvent extends DocumentedItem block.tag === '@returns') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') @@ -81,7 +75,6 @@ export class DocumentedEvent extends DocumentedItem block.tag === '@returns') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') diff --git a/packages/docgen/src/types/member.ts b/packages/docgen/src/types/member.ts index d25dbf3a3..581ce6bb8 100644 --- a/packages/docgen/src/types/member.ts +++ b/packages/docgen/src/types/member.ts @@ -18,7 +18,6 @@ export class DocumentedMember extends DocumentedItem block.tag === '@see').length ? signature.comment.blockTags .filter((block) => block.tag === '@see') @@ -27,20 +26,18 @@ export class DocumentedMember extends DocumentedItem (prev += curr.text), '').trim() || undefined, see, scope: data.flags.isStatic ? 'static' : undefined, access: data.flags.isPrivate || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition signature.comment?.blockTags?.some((block) => block.tag === '@private' || block.tag === '@internal') ? 'private' : undefined, readonly: data.flags.isReadonly, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing abstract: signature.comment?.blockTags?.some((block) => block.tag === '@abstract') || undefined, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition deprecated: signature.comment?.blockTags?.some((block) => block.tag === '@deprecated') ? signature.comment.blockTags .find((block) => block.tag === '@deprecated') @@ -51,7 +48,6 @@ export class DocumentedMember extends DocumentedItem block.tag === '@default') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') @@ -76,7 +72,6 @@ export class DocumentedMember extends DocumentedItem block.tag === '@see').length ? getter.comment.blockTags .filter((block) => block.tag === '@see') @@ -85,19 +80,17 @@ export class DocumentedMember extends DocumentedItem (prev += curr.text), '').trim() || undefined, see, access: data.flags.isPrivate || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition getter.comment?.blockTags?.some((block) => block.tag === '@private' || block.tag === '@internal') ? 'private' : undefined, readonly: base.readonly || !hasSetter, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing abstract: getter.comment?.blockTags?.some((block) => block.tag === '@abstract') || undefined, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition deprecated: getter.comment?.blockTags?.some((block) => block.tag === '@deprecated') ? getter.comment.blockTags .find((block) => block.tag === '@deprecated') @@ -108,7 +101,6 @@ export class DocumentedMember extends DocumentedItem block.tag === '@default') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') diff --git a/packages/docgen/src/types/method.ts b/packages/docgen/src/types/method.ts index cd20ab90c..013e22fde 100644 --- a/packages/docgen/src/types/method.ts +++ b/packages/docgen/src/types/method.ts @@ -18,14 +18,12 @@ export class DocumentedMethod extends DocumentedItem block.tag === '@see').length ? signature.comment.blockTags .filter((block) => block.tag === '@see') .map((block) => block.content.find((innerContent) => innerContent.kind === 'text')?.text.trim()) : undefined; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition const examples = signature.comment?.blockTags?.filter((block) => block.tag === '@example').length ? signature.comment.blockTags .filter((block) => block.tag === '@example') @@ -35,20 +33,18 @@ export class DocumentedMethod extends DocumentedItem (prev += curr.text), '').trim() || undefined, see, scope: data.flags.isStatic ? 'static' : undefined, access: data.flags.isPrivate || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition signature.comment?.blockTags?.some((block) => block.tag === '@private' || block.tag === '@internal') ? 'private' : undefined, examples, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing abstract: signature.comment?.blockTags?.some((block) => block.tag === '@abstract') || undefined, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition deprecated: signature.comment?.blockTags?.some((block) => block.tag === '@deprecated') ? signature.comment.blockTags .find((block) => block.tag === '@deprecated') @@ -56,7 +52,6 @@ export class DocumentedMethod extends DocumentedItem (prev += curr.text), '') .trim() ?? true : undefined, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // emits: signature.comment?.blockTags?.filter((t) => t.tag === '@emits').map((t) => t.content), // @ts-expect-error: Typescript doesn't know that this is a SignatureReflection params: signature.parameters @@ -71,7 +66,6 @@ export class DocumentedMethod extends DocumentedItem block.tag === '@returns') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') @@ -84,7 +78,6 @@ export class DocumentedMethod extends DocumentedItem block.tag === '@returns') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') diff --git a/packages/docgen/src/types/param.ts b/packages/docgen/src/types/param.ts index 9d4bfa36d..8c64148cc 100644 --- a/packages/docgen/src/types/param.ts +++ b/packages/docgen/src/types/param.ts @@ -11,13 +11,12 @@ export class DocumentedParam extends DocumentedItem return { name: data.name, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing, no-param-reassign + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, no-param-reassign description: data.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined, optional: data.flags.isOptional || typeof data.defaultValue !== 'undefined', default: (data.defaultValue === '...' ? undefined : data.defaultValue) ?? (data.comment?.blockTags - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition ?.find((block) => block.tag === '@default') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') diff --git a/packages/docgen/src/types/typedef.ts b/packages/docgen/src/types/typedef.ts index 17df02874..e41f9871e 100644 --- a/packages/docgen/src/types/typedef.ts +++ b/packages/docgen/src/types/typedef.ts @@ -19,7 +19,6 @@ export class DocumentedTypeDef extends DocumentedItem block.tag === '@see').length ? signature.comment.blockTags .filter((block) => block.tag === '@see') @@ -28,16 +27,14 @@ export class DocumentedTypeDef extends DocumentedItem (prev += curr.text), '').trim() || undefined, see, access: data.flags.isPrivate || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition signature.comment?.blockTags?.some((block) => block.tag === '@private' || block.tag === '@internal') ? 'private' : undefined, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition deprecated: signature.comment?.blockTags?.some((block) => block.tag === '@deprecated') ? signature.comment.blockTags .find((block) => block.tag === '@deprecated') @@ -64,7 +61,7 @@ export class DocumentedTypeDef extends DocumentedItem (prev += curr.text), '') // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing .trim() || undefined, @@ -82,18 +79,17 @@ export class DocumentedTypeDef extends DocumentedItem (prev += curr.text), '') // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing .trim() || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing, no-param-reassign + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, no-param-reassign child.signatures?.[0]?.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined, optional: child.flags.isOptional || typeof child.defaultValue !== 'undefined', default: (child.defaultValue === '...' ? undefined : child.defaultValue) ?? (child.comment?.blockTags - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition ?.find((block) => block.tag === '@default') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') @@ -112,7 +108,6 @@ export class DocumentedTypeDef extends DocumentedItem block.tag === '@returns') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') @@ -134,13 +129,12 @@ export class DocumentedTypeDef extends DocumentedItem ({ name: param.name, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing, no-param-reassign + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, no-param-reassign description: param.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined, optional: param.flags.isOptional || typeof param.defaultValue !== 'undefined', default: (param.defaultValue === '...' ? undefined : param.defaultValue) ?? (param.comment?.blockTags - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition ?.find((block) => block.tag === '@default') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') @@ -152,7 +146,6 @@ export class DocumentedTypeDef extends DocumentedItem block.tag === '@see').length ? sig.comment.blockTags .filter((block) => block.tag === '@see') @@ -161,16 +154,14 @@ export class DocumentedTypeDef extends DocumentedItem (prev += curr.text), '').trim() || undefined, see, access: sig?.flags.isPrivate || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition sig?.comment?.blockTags?.some((block) => block.tag === '@private' || block.tag === '@internal') ? 'private' : undefined, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition deprecated: sig?.comment?.blockTags?.some((block) => block.tag === '@deprecated') ? sig.comment.blockTags .find((block) => block.tag === '@deprecated') @@ -186,7 +177,6 @@ export class DocumentedTypeDef extends DocumentedItem block.tag === '@returns') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') @@ -199,7 +189,6 @@ export class DocumentedTypeDef extends DocumentedItem block.tag === '@returns') // eslint-disable-next-line no-param-reassign ?.content.reduce((prev, curr) => (prev += curr.text), '') diff --git a/packages/docgen/src/util/parseType.ts b/packages/docgen/src/util/parseType.ts index 06f7c17b5..d48b07831 100644 --- a/packages/docgen/src/util/parseType.ts +++ b/packages/docgen/src/util/parseType.ts @@ -91,7 +91,6 @@ export function parseType(someType: JSONOutput.SomeType | JSONOutput.Type | stri return `'${someType.value}'`; } - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions return `${someType.value}`; } diff --git a/packages/docgen/src/util/types.ts b/packages/docgen/src/util/types.ts index b2270fcb4..89154111b 100644 --- a/packages/docgen/src/util/types.ts +++ b/packages/docgen/src/util/types.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import type { JSONOutput } from 'typedoc'; interface QueryType { diff --git a/packages/proxy-container/src/index.ts b/packages/proxy-container/src/index.ts index 48284a8c1..dff6f964e 100644 --- a/packages/proxy-container/src/index.ts +++ b/packages/proxy-container/src/index.ts @@ -9,7 +9,6 @@ if (!process.env.DISCORD_TOKEN) { // We want to let upstream handle retrying const api = new REST({ rejectOnRateLimit: () => true, retries: 0 }).setToken(process.env.DISCORD_TOKEN); -// eslint-disable-next-line @typescript-eslint/no-misused-promises const server = createServer(proxyRequests(api)); const port = Number.parseInt(process.env.PORT ?? '8080', 10); diff --git a/packages/proxy/__tests__/proxyRequests.test.ts b/packages/proxy/__tests__/proxyRequests.test.ts index f956958be..6069fda2b 100644 --- a/packages/proxy/__tests__/proxyRequests.test.ts +++ b/packages/proxy/__tests__/proxyRequests.test.ts @@ -16,7 +16,6 @@ const responseOptions: MockInterceptor.MockResponseOptions = { }; const api = new REST().setToken('A-Very-Fake-Token'); -// eslint-disable-next-line @typescript-eslint/no-misused-promises const server = createServer(proxyRequests(api)); beforeEach(() => { diff --git a/packages/rest/__tests__/RequestHandler.test.ts b/packages/rest/__tests__/RequestHandler.test.ts index 2bd7330a5..6c846d6f1 100644 --- a/packages/rest/__tests__/RequestHandler.test.ts +++ b/packages/rest/__tests__/RequestHandler.test.ts @@ -58,7 +58,6 @@ const sublimit = { body: { name: 'newname' } }; const noSublimit = { body: { bitrate: 40_000 } }; function startSublimitIntervals() { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!sublimitIntervals.reset) { sublimitResetAfter = Date.now() + 250; sublimitIntervals.reset = setInterval(() => { @@ -67,7 +66,6 @@ function startSublimitIntervals() { }, 250); } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!sublimitIntervals.retry) { retryAfter = Date.now() + 1_000; sublimitIntervals.retry = setInterval(() => { diff --git a/packages/rest/__tests__/Util.test.ts b/packages/rest/__tests__/Util.test.ts index 76504b974..ad4cbb5c7 100644 --- a/packages/rest/__tests__/Util.test.ts +++ b/packages/rest/__tests__/Util.test.ts @@ -62,7 +62,7 @@ test('resolveBody', async () => { }; await expect(resolveBody(asyncIterable)).resolves.toStrictEqual(Buffer.from([1, 2, 3, 1, 2, 3, 1, 2, 3])); - // unknown type - // @ts-expect-error This test is ensuring that this throws + // Unknown type + // @ts-expect-error: This test is ensuring that this throws await expect(resolveBody(true)).rejects.toThrow(TypeError); }); diff --git a/packages/rest/src/lib/REST.ts b/packages/rest/src/lib/REST.ts index 7b2a1afd4..d4bd5f5b7 100644 --- a/packages/rest/src/lib/REST.ts +++ b/packages/rest/src/lib/REST.ts @@ -11,7 +11,7 @@ import { type RequestData, type RouteLike, } from './RequestManager.js'; -import type { IHandler } from './handlers/IHandler'; +import type { IHandler } from './handlers/IHandler.js'; import { DefaultRestOptions, RESTEvents } from './utils/constants.js'; import { parseResponse } from './utils/utils.js'; diff --git a/packages/rest/src/lib/RequestManager.ts b/packages/rest/src/lib/RequestManager.ts index 594ad128d..10a30bb5a 100644 --- a/packages/rest/src/lib/RequestManager.ts +++ b/packages/rest/src/lib/RequestManager.ts @@ -5,8 +5,8 @@ import type { URLSearchParams } from 'node:url'; import { Collection } from '@discordjs/collection'; import { DiscordSnowflake } from '@sapphire/snowflake'; import { FormData, type RequestInit, type BodyInit, type Dispatcher, type Agent } from 'undici'; -import type { RESTOptions, RestEvents, RequestOptions } from './REST'; -import type { IHandler } from './handlers/IHandler'; +import type { RESTOptions, RestEvents, RequestOptions } from './REST.js'; +import type { IHandler } from './handlers/IHandler.js'; import { SequentialHandler } from './handlers/SequentialHandler.js'; import { DefaultRestOptions, DefaultUserAgent, RESTEvents } from './utils/constants.js'; import { resolveBody } from './utils/utils.js'; @@ -208,7 +208,6 @@ export class RequestManager extends EventEmitter { */ public readonly handlers = new Collection(); - // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility #token: string | null = null; private hashTimer!: NodeJS.Timer; @@ -422,7 +421,6 @@ export class RequestManager extends EventEmitter { const contentType = file.contentType ?? (await fileTypeFromBuffer(file.data))?.mime; formData.append(fileKey, new Blob([file.data], { type: contentType }), file.name); } else { - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name); } } @@ -457,7 +455,6 @@ export class RequestManager extends EventEmitter { finalBody = await resolveBody(finalBody); const fetchOptions: RequestOptions = { - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions headers: { ...request.headers, ...additionalHeaders, ...headers } as Record, method: request.method.toUpperCase() as Dispatcher.HttpMethod, }; diff --git a/packages/rest/src/lib/errors/DiscordAPIError.ts b/packages/rest/src/lib/errors/DiscordAPIError.ts index 54341f3ad..9f03cbf3c 100644 --- a/packages/rest/src/lib/errors/DiscordAPIError.ts +++ b/packages/rest/src/lib/errors/DiscordAPIError.ts @@ -101,13 +101,11 @@ export class DiscordAPIError extends Error { if (typeof val === 'string') { yield val; - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument } else if (isErrorGroupWrapper(val)) { for (const error of val._errors) { yield* this.flattenDiscordError(error, nextKey); } } else { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument yield* this.flattenDiscordError(val, nextKey); } } diff --git a/packages/rest/src/lib/handlers/IHandler.ts b/packages/rest/src/lib/handlers/IHandler.ts index 8471829f5..d1c0b6c11 100644 --- a/packages/rest/src/lib/handlers/IHandler.ts +++ b/packages/rest/src/lib/handlers/IHandler.ts @@ -10,7 +10,6 @@ export interface IHandler { /** * If the bucket is currently inactive (no pending requests) */ - // eslint-disable-next-line @typescript-eslint/method-signature-style -- This is meant to be a getter returning a bool get inactive(): boolean; /** * Queues a request to be sent diff --git a/packages/rest/src/lib/handlers/SequentialHandler.ts b/packages/rest/src/lib/handlers/SequentialHandler.ts index bb5447ea0..fa432f672 100644 --- a/packages/rest/src/lib/handlers/SequentialHandler.ts +++ b/packages/rest/src/lib/handlers/SequentialHandler.ts @@ -53,25 +53,21 @@ export class SequentialHandler implements IHandler { /** * The interface used to sequence async requests sequentially */ - // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility #asyncQueue = new AsyncQueue(); /** * The interface used to sequence sublimited async requests sequentially */ - // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility #sublimitedQueue: AsyncQueue | null = null; /** * A promise wrapper for when the sublimited queue is finished being processed or null when not being processed */ - // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility #sublimitPromise: { promise: Promise; resolve(): void } | null = null; /** * Whether the sublimit queue needs to be shifted in the finally block */ - // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility #shiftSublimit = false; /** diff --git a/packages/rest/src/lib/utils/constants.ts b/packages/rest/src/lib/utils/constants.ts index 2c5106572..296016370 100644 --- a/packages/rest/src/lib/utils/constants.ts +++ b/packages/rest/src/lib/utils/constants.ts @@ -2,10 +2,9 @@ import process from 'node:process'; import { APIVersion } from 'discord-api-types/v10'; import { getGlobalDispatcher } from 'undici'; 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 +// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports const Package = require('../../../package.json'); -// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access export const DefaultUserAgent = `DiscordBot (${Package.homepage}, ${Package.version})`; export const DefaultRestOptions: Required = { diff --git a/packages/rest/src/lib/utils/utils.ts b/packages/rest/src/lib/utils/utils.ts index 3cc69a5c8..97158e997 100644 --- a/packages/rest/src/lib/utils/utils.ts +++ b/packages/rest/src/lib/utils/utils.ts @@ -113,7 +113,6 @@ export async function resolveBody(body: RequestInit['body']): Promise)[Symbol.iterator]) { const chunks = [...(body as Iterable)]; const length = chunks.reduce((a, b) => a + b.length, 0); @@ -126,7 +125,6 @@ export async function resolveBody(body: RequestInit['body']): Promise)[Symbol.asyncIterator]) { const chunks: Uint8Array[] = []; diff --git a/packages/voice/__tests__/AudioPlayer.test.ts b/packages/voice/__tests__/AudioPlayer.test.ts index 544b25262..a7189d6c4 100644 --- a/packages/voice/__tests__/AudioPlayer.test.ts +++ b/packages/voice/__tests__/AudioPlayer.test.ts @@ -1,6 +1,4 @@ /* eslint-disable @typescript-eslint/unbound-method */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/dot-notation */ import { Buffer } from 'node:buffer'; import { once } from 'node:events'; @@ -8,7 +6,7 @@ import process from 'node:process'; import { Readable } from 'node:stream'; import { addAudioPlayer, deleteAudioPlayer } from '../src/DataStore'; import { VoiceConnection, VoiceConnectionStatus } from '../src/VoiceConnection'; -import { createAudioPlayer, AudioPlayerStatus, SILENCE_FRAME, type AudioPlayerState } from '../src/audio/AudioPlayer'; +import { createAudioPlayer, AudioPlayerStatus, SILENCE_FRAME } from '../src/audio/AudioPlayer'; import { AudioPlayerError } from '../src/audio/AudioPlayerError'; import { AudioResource } from '../src/audio/AudioResource'; import { NoSubscriberBehavior } from '../src/index'; @@ -23,7 +21,6 @@ const AudioPlayerErrorMock = AudioPlayerError as unknown as jest.Mock; function* silence() { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition while (true) { yield Buffer.from([0xf8, 0xff, 0xfe]); } diff --git a/packages/voice/__tests__/AudioResource.test.ts b/packages/voice/__tests__/AudioResource.test.ts index 9a1bb2872..383195eac 100644 --- a/packages/voice/__tests__/AudioResource.test.ts +++ b/packages/voice/__tests__/AudioResource.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-return */ import { Buffer } from 'node:buffer'; import process from 'node:process'; import { PassThrough, Readable } from 'node:stream'; @@ -26,7 +25,7 @@ async function started(resource: AudioResource) { const findPipeline = _findPipeline as unknown as jest.MockedFunction; beforeAll(() => { - // @ts-expect-error no type + // @ts-expect-error: No type findPipeline.mockImplementation((from: StreamType, constraint: (path: Edge[]) => boolean) => { const base = [ { @@ -38,7 +37,6 @@ beforeAll(() => { if (constraint === VOLUME_CONSTRAINT) { base.push({ cost: 1, - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument transformer: () => new VolumeTransformer({} as any), type: TransformerType.InlineVolume, }); @@ -98,7 +96,6 @@ describe('createAudioResource', () => { }); test('Infers from VolumeTransformer', () => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const stream = new VolumeTransformer({} as any); const resource = createAudioResource(stream, { inlineVolume: true }); expect(findPipeline).toHaveBeenCalledWith(StreamType.Raw, NO_CONSTRAINT); diff --git a/packages/voice/__tests__/DataStore.test.ts b/packages/voice/__tests__/DataStore.test.ts index 78930d46b..5ed445ab8 100644 --- a/packages/voice/__tests__/DataStore.test.ts +++ b/packages/voice/__tests__/DataStore.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/dot-notation */ import { GatewayOpcodes } from 'discord-api-types/v10'; import * as DataStore from '../src/DataStore'; diff --git a/packages/voice/__tests__/SSRCMap.test.ts b/packages/voice/__tests__/SSRCMap.test.ts index 1da3f26e8..4c27acdd7 100644 --- a/packages/voice/__tests__/SSRCMap.test.ts +++ b/packages/voice/__tests__/SSRCMap.test.ts @@ -1,6 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import type EventEmitter from 'node:events'; -import { once } from 'node:events'; +import { type EventEmitter, once } from 'node:events'; import process from 'node:process'; import { SSRCMap, type VoiceUserData } from '../src/receive/SSRCMap'; diff --git a/packages/voice/__tests__/VoiceConnection.test.ts b/packages/voice/__tests__/VoiceConnection.test.ts index c6f0a2e80..e8d17dbbf 100644 --- a/packages/voice/__tests__/VoiceConnection.test.ts +++ b/packages/voice/__tests__/VoiceConnection.test.ts @@ -1,10 +1,6 @@ /* eslint-disable @typescript-eslint/unbound-method */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable @typescript-eslint/no-unsafe-return */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/dot-notation */ -import EventEmitter from 'node:events'; +import { EventEmitter } from 'node:events'; import * as _DataStore from '../src/DataStore'; import { createVoiceConnection, diff --git a/packages/voice/__tests__/VoiceReceiver.test.ts b/packages/voice/__tests__/VoiceReceiver.test.ts index 534911b68..36cb9ce4a 100644 --- a/packages/voice/__tests__/VoiceReceiver.test.ts +++ b/packages/voice/__tests__/VoiceReceiver.test.ts @@ -1,5 +1,4 @@ /* eslint-disable id-length */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/dot-notation */ import { Buffer } from 'node:buffer'; import { once } from 'node:events'; @@ -39,7 +38,6 @@ describe('VoiceReceiver', () => { let receiver: VoiceReceiver; beforeEach(() => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument voiceConnection = new VoiceConnection({} as any, {} as any); voiceConnection.state = { status: VoiceConnectionStatus.Signalling, diff --git a/packages/voice/__tests__/VoiceUDPSocket.test.ts b/packages/voice/__tests__/VoiceUDPSocket.test.ts index 28c79dca3..b78969d5b 100644 --- a/packages/voice/__tests__/VoiceUDPSocket.test.ts +++ b/packages/voice/__tests__/VoiceUDPSocket.test.ts @@ -1,9 +1,6 @@ -/* eslint-disable @typescript-eslint/no-unsafe-return */ -/* eslint-disable @typescript-eslint/no-empty-function */ -/* eslint-disable @typescript-eslint/no-unused-vars */ import { Buffer } from 'node:buffer'; import { createSocket as _createSocket } from 'node:dgram'; -import EventEmitter, { once } from 'node:events'; +import { EventEmitter } from 'node:events'; import { VoiceUDPSocket } from '../src/networking/VoiceUDPSocket'; jest.mock('node:dgram'); diff --git a/packages/voice/__tests__/VoiceWebSocket.test.ts b/packages/voice/__tests__/VoiceWebSocket.test.ts index 027ebe9c7..cf636c545 100644 --- a/packages/voice/__tests__/VoiceWebSocket.test.ts +++ b/packages/voice/__tests__/VoiceWebSocket.test.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { type EventEmitter, once } from 'node:events'; import { VoiceOpcodes } from 'discord-api-types/voice/v4'; import WS from 'jest-websocket-mock'; @@ -115,7 +113,6 @@ describe.skip('VoiceWebSocket: heartbeating', () => { const endpoint = 'ws://localhost:1234'; const server = new WS(endpoint, { jsonProtocol: true }); const ws = new VoiceWebSocket(endpoint, false); - // eslint-disable-next-line @typescript-eslint/no-empty-function ws.on('error', () => {}); await server.connected; const rcv = onceIgnoreError(ws, 'close'); diff --git a/packages/voice/__tests__/demuxProbe.test.ts b/packages/voice/__tests__/demuxProbe.test.ts index a6fd78865..981517e46 100644 --- a/packages/voice/__tests__/demuxProbe.test.ts +++ b/packages/voice/__tests__/demuxProbe.test.ts @@ -1,6 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Buffer } from 'node:buffer'; import EventEmitter, { once } from 'node:events'; import process from 'node:process'; @@ -27,8 +24,7 @@ async function* gen(num: number) { } function range(num: number) { - // eslint-disable-next-line unicorn/no-new-array - return Buffer.from(Array.from(new Array(num).keys())); + return Buffer.from(Array.from(Array.from({ length: num }).keys())); } const validHead = Buffer.from([ @@ -80,7 +76,6 @@ describe('demuxProbe', () => { test('Detects WebM', async () => { const stream = Readable.from(gen(10), { objectMode: false }); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument webmWrite.mockImplementation(function mock(data: Buffer) { if (data[0] === 5) this.emit('head', validHead); } as any); @@ -91,7 +86,6 @@ describe('demuxProbe', () => { test('Detects Ogg', async () => { const stream = Readable.from(gen(10), { objectMode: false }); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument oggWrite.mockImplementation(function mock(data: Buffer) { if (data[0] === 5) this.emit('head', validHead); } as any); @@ -102,7 +96,6 @@ describe('demuxProbe', () => { test('Rejects invalid OpusHead', async () => { const stream = Readable.from(gen(10), { objectMode: false }); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument oggWrite.mockImplementation(function mock(data: Buffer) { if (data[0] === 5) this.emit('head', invalidHead); } as any); diff --git a/packages/voice/__tests__/entersState.test.ts b/packages/voice/__tests__/entersState.test.ts index e2f10d888..3b8cb626f 100644 --- a/packages/voice/__tests__/entersState.test.ts +++ b/packages/voice/__tests__/entersState.test.ts @@ -1,6 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import EventEmitter from 'node:events'; +import { EventEmitter } from 'node:events'; import process from 'node:process'; import { VoiceConnectionStatus, type VoiceConnection } from '../src/VoiceConnection'; import { entersState } from '../src/util/entersState'; @@ -19,7 +17,6 @@ describe('entersState', () => { test('Returns the target once the state has been entered before timeout', async () => { jest.useRealTimers(); const vc = createFakeVoiceConnection(); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument process.nextTick(() => vc.emit(VoiceConnectionStatus.Ready, null as any, null as any)); const result = await entersState(vc, VoiceConnectionStatus.Ready, 1_000); expect(result).toEqual(vc); @@ -36,7 +33,6 @@ describe('entersState', () => { jest.useRealTimers(); const vc = createFakeVoiceConnection(); const ac = new AbortController(); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument process.nextTick(() => vc.emit(VoiceConnectionStatus.Ready, null as any, null as any)); const result = await entersState(vc, VoiceConnectionStatus.Ready, ac.signal); expect(result).toEqual(vc); diff --git a/packages/voice/__tests__/joinVoiceChannel.test.ts b/packages/voice/__tests__/joinVoiceChannel.test.ts index ec9613877..9926167f9 100644 --- a/packages/voice/__tests__/joinVoiceChannel.test.ts +++ b/packages/voice/__tests__/joinVoiceChannel.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-return */ import * as VoiceConnection from '../src/VoiceConnection'; import { joinVoiceChannel } from '../src/joinVoiceChannel'; diff --git a/packages/voice/examples/recorder/src/bot.ts b/packages/voice/examples/recorder/src/bot.ts index d66a53b78..8e7555008 100644 --- a/packages/voice/examples/recorder/src/bot.ts +++ b/packages/voice/examples/recorder/src/bot.ts @@ -4,7 +4,6 @@ import Discord, { Interaction, Constants } from 'discord.js'; import { deploy } from './deploy'; import { interactionHandlers } from './interactions'; -// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports const { token } = require('../auth.json') as { token: string }; const client = new Discord.Client({ diff --git a/packages/voice/src/DataStore.ts b/packages/voice/src/DataStore.ts index 6e987aef5..cc726a3ab 100644 --- a/packages/voice/src/DataStore.ts +++ b/packages/voice/src/DataStore.ts @@ -1,6 +1,6 @@ import { GatewayOpcodes } from 'discord-api-types/v10'; import type { VoiceConnection } from './VoiceConnection'; -import type { AudioPlayer } from './audio'; +import type { AudioPlayer } from './audio/index'; export interface JoinConfig { channelId: string | null; diff --git a/packages/voice/src/VoiceConnection.ts b/packages/voice/src/VoiceConnection.ts index d77fe2af8..2dee81eef 100644 --- a/packages/voice/src/VoiceConnection.ts +++ b/packages/voice/src/VoiceConnection.ts @@ -325,7 +325,6 @@ export class VoiceConnection extends EventEmitter { this.emit('stateChange', oldState, newState); if (oldState.status !== newState.status) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.emit(newState.status, oldState, newState as any); } } @@ -391,7 +390,6 @@ export class VoiceConnection extends EventEmitter { newUdp?.on('message', this.receiver.onUdpMessage); } - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment this.receiver.connectionData = Reflect.get(newState, 'connectionData') ?? {}; } diff --git a/packages/voice/src/audio/AudioPlayer.ts b/packages/voice/src/audio/AudioPlayer.ts index a5a25acd8..2b945e085 100644 --- a/packages/voice/src/audio/AudioPlayer.ts +++ b/packages/voice/src/audio/AudioPlayer.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/prefer-ts-expect-error, @typescript-eslint/method-signature-style */ import { Buffer } from 'node:buffer'; -import EventEmitter from 'node:events'; +import { EventEmitter } from 'node:events'; import { addAudioPlayer, deleteAudioPlayer } from '../DataStore'; import { VoiceConnectionStatus, type VoiceConnection } from '../VoiceConnection'; import { noop } from '../util/util'; @@ -356,7 +356,6 @@ export class AudioPlayer extends EventEmitter { this.emit('stateChange', oldState, this._state); if (oldState.status !== newState.status || didChangeResources) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.emit(newState.status, oldState, this._state as any); } @@ -600,7 +599,6 @@ export class AudioPlayer extends EventEmitter { */ const packet: Buffer | null = state.resource.read(); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (state.status === AudioPlayerStatus.Playing) { if (packet) { this._preparePacket(packet, playable, state); diff --git a/packages/voice/src/networking/Networking.ts b/packages/voice/src/networking/Networking.ts index af53da869..7390b6bd8 100644 --- a/packages/voice/src/networking/Networking.ts +++ b/packages/voice/src/networking/Networking.ts @@ -387,22 +387,16 @@ export class Networking extends EventEmitter { * @param packet - The received packet */ private onWsPacket(packet: any) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (packet.op === VoiceOpcodes.Hello && this.state.code !== NetworkingStatusCode.Closed) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access this.state.ws.setHeartbeatInterval(packet.d.heartbeat_interval); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access } else if (packet.op === VoiceOpcodes.Ready && this.state.code === NetworkingStatusCode.Identifying) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access const { ip, port, ssrc, modes } = packet.d; - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const udp = new VoiceUDPSocket({ ip, port }); udp.on('error', this.onChildError); udp.on('debug', this.onUdpDebug); udp.once('close', this.onUdpClose); udp - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument .performIPDiscovery(ssrc) // eslint-disable-next-line promise/prefer-await-to-then .then((localConfig) => { @@ -414,7 +408,6 @@ export class Networking extends EventEmitter { data: { address: localConfig.ip, port: localConfig.port, - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument mode: chooseEncryptionMode(modes), }, }, @@ -432,25 +425,20 @@ export class Networking extends EventEmitter { code: NetworkingStatusCode.UdpHandshaking, udp, connectionData: { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment ssrc, }, }; } else if ( - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access packet.op === VoiceOpcodes.SessionDescription && this.state.code === NetworkingStatusCode.SelectingProtocol ) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access const { mode: encryptionMode, secret_key: secretKey } = packet.d; this.state = { ...this.state, code: NetworkingStatusCode.Ready, connectionData: { ...this.state.connectionData, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment encryptionMode, - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument secretKey: new Uint8Array(secretKey), sequence: randomNBit(16), timestamp: randomNBit(32), @@ -460,7 +448,6 @@ export class Networking extends EventEmitter { packetsPlayed: 0, }, }; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access } else if (packet.op === VoiceOpcodes.Resumed && this.state.code === NetworkingStatusCode.Resuming) { this.state = { ...this.state, diff --git a/packages/voice/src/networking/VoiceWebSocket.ts b/packages/voice/src/networking/VoiceWebSocket.ts index 4c8cd1dd0..eb2278735 100644 --- a/packages/voice/src/networking/VoiceWebSocket.ts +++ b/packages/voice/src/networking/VoiceWebSocket.ts @@ -73,7 +73,6 @@ export class VoiceWebSocket extends EventEmitter { this.ws = new WebSocket(address); this.ws.onmessage = (err) => this.onMessage(err); this.ws.onopen = (err) => this.emit('open', err); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.ws.onerror = (err: Error | WebSocket.ErrorEvent) => this.emit('error', err instanceof Error ? err : err.error); this.ws.onclose = (err) => this.emit('close', err); @@ -110,7 +109,6 @@ export class VoiceWebSocket extends EventEmitter { let packet: any; try { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment packet = JSON.parse(event.data); } catch (error) { const err = error as Error; @@ -118,7 +116,6 @@ export class VoiceWebSocket extends EventEmitter { return; } - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (packet.op === VoiceOpcodes.HeartbeatAck) { this.lastHeartbeatAck = Date.now(); this.missedHeartbeats = 0; diff --git a/packages/voice/src/receive/AudioReceiveStream.ts b/packages/voice/src/receive/AudioReceiveStream.ts index ac25a026d..105eaa8db 100644 --- a/packages/voice/src/receive/AudioReceiveStream.ts +++ b/packages/voice/src/receive/AudioReceiveStream.ts @@ -85,6 +85,5 @@ export class AudioReceiveStream extends Readable { this.endTimeout = setTimeout(() => this.push(null), end.duration); } - // eslint-disable-next-line @typescript-eslint/no-empty-function public override _read() {} } diff --git a/packages/voice/src/receive/VoiceReceiver.ts b/packages/voice/src/receive/VoiceReceiver.ts index f4d21229c..4657d7e07 100644 --- a/packages/voice/src/receive/VoiceReceiver.ts +++ b/packages/voice/src/receive/VoiceReceiver.ts @@ -64,34 +64,22 @@ export class VoiceReceiver { * @internal */ public onWsPacket(packet: any) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (packet.op === VoiceOpcodes.ClientDisconnect && typeof packet.d?.user_id === 'string') { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access this.ssrcMap.delete(packet.d.user_id); } else if ( - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access packet.op === VoiceOpcodes.Speaking && - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access typeof packet.d?.user_id === 'string' && - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access typeof packet.d?.ssrc === 'number' ) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access this.ssrcMap.update({ userId: packet.d.user_id, audioSSRC: packet.d.ssrc }); } else if ( - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access packet.op === VoiceOpcodes.ClientConnect && - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access typeof packet.d?.user_id === 'string' && - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access typeof packet.d?.audio_ssrc === 'number' ) { this.ssrcMap.update({ - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access userId: packet.d.user_id, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access audioSSRC: packet.d.audio_ssrc, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access videoSSRC: packet.d.video_ssrc === 0 ? undefined : packet.d.video_ssrc, }); } diff --git a/packages/voice/src/util/Secretbox.ts b/packages/voice/src/util/Secretbox.ts index 644cdcf76..9a43833ad 100644 --- a/packages/voice/src/util/Secretbox.ts +++ b/packages/voice/src/util/Secretbox.ts @@ -9,56 +9,40 @@ interface Methods { const libs = { 'sodium-native': (sodium: any): Methods => ({ open: (buffer: Buffer, nonce: Buffer, secretKey: Uint8Array) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (buffer) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access const output = Buffer.allocUnsafe(buffer.length - sodium.crypto_box_MACBYTES); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call if (sodium.crypto_secretbox_open_easy(output, buffer, nonce, secretKey)) return output; } return null; }, close: (opusPacket: Buffer, nonce: Buffer, secretKey: Uint8Array) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/restrict-plus-operands + // eslint-disable-next-line @typescript-eslint/restrict-plus-operands const output = Buffer.allocUnsafe(opusPacket.length + sodium.crypto_box_MACBYTES); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call sodium.crypto_secretbox_easy(output, opusPacket, nonce, secretKey); return output; }, - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument random: (num: number, buffer: Buffer = Buffer.allocUnsafe(num)) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call sodium.randombytes_buf(buffer); return buffer; }, }), sodium: (sodium: any): Methods => ({ - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access open: sodium.api.crypto_secretbox_open_easy, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access close: sodium.api.crypto_secretbox_easy, - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument random: (num: number, buffer: Buffer = Buffer.allocUnsafe(num)) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call sodium.api.randombytes_buf(buffer); return buffer; }, }), 'libsodium-wrappers': (sodium: any): Methods => ({ - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access open: sodium.crypto_secretbox_open_easy, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access close: sodium.crypto_secretbox_easy, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access random: sodium.randombytes_buf, }), tweetnacl: (tweetnacl: any): Methods => ({ - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access open: tweetnacl.secretbox.open, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access close: tweetnacl.secretbox, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access random: tweetnacl.randomBytes, }), } as const; @@ -82,7 +66,6 @@ void (async () => { try { // eslint-disable-next-line unicorn/no-abusive-eslint-disable, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires const lib = require(libName); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (libName === 'libsodium-wrappers' && lib.ready) await lib.ready; Object.assign(methods, libs[libName](lib)); break; diff --git a/packages/voice/src/util/abortAfter.ts b/packages/voice/src/util/abortAfter.ts index 33b1eee62..8abc133af 100644 --- a/packages/voice/src/util/abortAfter.ts +++ b/packages/voice/src/util/abortAfter.ts @@ -7,7 +7,6 @@ export function abortAfter(delay: number): [AbortController, AbortSignal] { const ac = new AbortController(); const timeout = setTimeout(() => ac.abort(), delay); // @ts-expect-error: No type for timeout - // eslint-disable-next-line @typescript-eslint/no-unsafe-call ac.signal.addEventListener('abort', () => clearTimeout(timeout)); return [ac, ac.signal]; } diff --git a/packages/voice/src/util/generateDependencyReport.ts b/packages/voice/src/util/generateDependencyReport.ts index 08d712daf..d8808bca1 100644 --- a/packages/voice/src/util/generateDependencyReport.ts +++ b/packages/voice/src/util/generateDependencyReport.ts @@ -18,11 +18,8 @@ function findPackageJSON( if (depth === 0) return undefined; const attemptedPath = resolve(dir, './package.json'); try { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const pkg = require(attemptedPath); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (pkg.name !== packageName) throw new Error('package.json does not match'); - // eslint-disable-next-line @typescript-eslint/no-unsafe-return return pkg; } catch { return findPackageJSON(resolve(dir, '..'), packageName, depth - 1); @@ -36,12 +33,10 @@ function findPackageJSON( */ function version(name: string): string { try { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const pkg = name === '@discordjs/voice' ? require('../../package.json') : findPackageJSON(dirname(require.resolve(name)), name, 3); - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access return pkg?.version ?? 'not found'; } catch { return 'not found'; diff --git a/packages/voice/src/util/util.ts b/packages/voice/src/util/util.ts index 4b1407a80..f2d5e31d0 100644 --- a/packages/voice/src/util/util.ts +++ b/packages/voice/src/util/util.ts @@ -1,2 +1 @@ -// eslint-disable-next-line @typescript-eslint/no-empty-function export const noop = () => {}; diff --git a/packages/website/src/components/SidebarItems.tsx b/packages/website/src/components/SidebarItems.tsx index 6d15a6378..a190e5751 100644 --- a/packages/website/src/components/SidebarItems.tsx +++ b/packages/website/src/components/SidebarItems.tsx @@ -67,7 +67,6 @@ function resolveIcon(item: keyof GroupedMembers) { } const useStyles = createStyles((theme) => ({ - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment link: { ...theme.fn.focusStyles(), fontWeight: 500, diff --git a/packages/website/src/components/TableOfContentItems.tsx b/packages/website/src/components/TableOfContentItems.tsx index 5651c9185..89e1452fe 100644 --- a/packages/website/src/components/TableOfContentItems.tsx +++ b/packages/website/src/components/TableOfContentItems.tsx @@ -4,7 +4,6 @@ import { useMemo } from 'react'; import { VscListSelection, VscSymbolMethod, VscSymbolProperty } from 'react-icons/vsc'; const useStyles = createStyles((theme) => ({ - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment link: { ...theme.fn.focusStyles(), fontWeight: 500, diff --git a/packages/website/src/pages/docs/[...slug].tsx b/packages/website/src/pages/docs/[...slug].tsx index a1bf8d0e9..61be19086 100644 --- a/packages/website/src/pages/docs/[...slug].tsx +++ b/packages/website/src/pages/docs/[...slug].tsx @@ -47,16 +47,13 @@ export const getStaticPaths: GetStaticPaths = async () => { let versions: string[] = []; if (process.env.NEXT_PUBLIC_LOCAL_DEV) { const res = await readFile(join(cwd(), '..', packageName, 'docs', 'docs.api.json'), 'utf8'); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment data = JSON.parse(res); } else { const response = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment versions = await response.json(); for (const version of versions) { const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${version}.api.json`); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment data = [...data, await res.json()]; } } @@ -142,11 +139,9 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { let data; if (process.env.NEXT_PUBLIC_LOCAL_DEV) { const res = await readFile(join(cwd(), '..', packageName, 'docs', 'docs.api.json'), 'utf8'); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment data = JSON.parse(res); } else { const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${branchName}.api.json`); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment data = await res.json(); } diff --git a/packages/website/src/pages/docs/packages/[package]/index.tsx b/packages/website/src/pages/docs/packages/[package]/index.tsx index 6f6bbaf89..756747901 100644 --- a/packages/website/src/pages/docs/packages/[package]/index.tsx +++ b/packages/website/src/pages/docs/packages/[package]/index.tsx @@ -38,7 +38,6 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { try { const res = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName ?? 'builders'}`); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const data: string[] = await res.json(); if (!data.length) { diff --git a/packages/website/src/util/api-model.server.ts b/packages/website/src/util/api-model.server.ts index db961a41e..3753a0f6a 100644 --- a/packages/website/src/util/api-model.server.ts +++ b/packages/website/src/util/api-model.server.ts @@ -1,6 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ - import { ApiModel, ApiItem, type ApiPackage } from '@microsoft/api-extractor-model'; import { TSDocConfiguration } from '@microsoft/tsdoc'; import { TSDocConfigFile } from '@microsoft/tsdoc-config'; @@ -11,7 +8,6 @@ export function createApiModel(data: any) { const tsdocConfigFile = TSDocConfigFile.loadFromObject(data.metadata.tsdocConfig); tsdocConfigFile.configureParser(tsdocConfiguration); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const apiPackage = ApiItem.deserialize(data, { apiJsonFilename: '', toolPackage: data.metadata.toolPackage, diff --git a/packages/ws/__tests__/strategy/WorkerShardingStrategy.test.ts b/packages/ws/__tests__/strategy/WorkerShardingStrategy.test.ts index 69ace627b..4ba57fa83 100644 --- a/packages/ws/__tests__/strategy/WorkerShardingStrategy.test.ts +++ b/packages/ws/__tests__/strategy/WorkerShardingStrategy.test.ts @@ -50,14 +50,12 @@ vi.mock('node:worker_threads', async () => { class MockWorker extends EventEmitter { public constructor(...args: any[]) { super(); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument mockConstructor(...args); // need to delay this by an event loop cycle to allow the strategy to attach a listener setImmediate(() => this.emit('online')); } public postMessage(message: WorkerSendPayload) { - // eslint-disable-next-line default-case switch (message.op) { case WorkerSendPayloadOp.Connect: { const response: WorkerRecievePayload = { @@ -180,7 +178,6 @@ test('spawn, connect, send a message, session info, and destroy', async () => { await manager.connect(); expect(mockConstructor).toHaveBeenCalledWith( expect.stringContaining('worker.cjs'), - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment expect.objectContaining({ workerData: expect.objectContaining({ shardIds: [0, 1] }) }), ); diff --git a/packages/ws/src/strategies/context/WorkerContextFetchingStrategy.ts b/packages/ws/src/strategies/context/WorkerContextFetchingStrategy.ts index 5ada996f1..d7c24a402 100644 --- a/packages/ws/src/strategies/context/WorkerContextFetchingStrategy.ts +++ b/packages/ws/src/strategies/context/WorkerContextFetchingStrategy.ts @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/require-post-message-target-origin */ import { isMainThread, parentPort } from 'node:worker_threads'; import { Collection } from '@discordjs/collection'; import type { SessionInfo } from '../../ws/WebSocketManager.js'; @@ -35,7 +36,6 @@ export class WorkerContextFetchingStrategy implements IContextFetchingStrategy { }; // eslint-disable-next-line no-promise-executor-return const promise = new Promise((resolve) => this.sessionPromises.set(nonce, resolve)); - // eslint-disable-next-line unicorn/require-post-message-target-origin parentPort!.postMessage(payload); return promise; } @@ -46,7 +46,6 @@ export class WorkerContextFetchingStrategy implements IContextFetchingStrategy { shardId, session: sessionInfo, }; - // eslint-disable-next-line unicorn/require-post-message-target-origin parentPort!.postMessage(payload); } } diff --git a/packages/ws/src/strategies/sharding/WorkerShardingStrategy.ts b/packages/ws/src/strategies/sharding/WorkerShardingStrategy.ts index bfc8f2436..47d767e8a 100644 --- a/packages/ws/src/strategies/sharding/WorkerShardingStrategy.ts +++ b/packages/ws/src/strategies/sharding/WorkerShardingStrategy.ts @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/require-post-message-target-origin */ import { once } from 'node:events'; import { join } from 'node:path'; import { Worker } from 'node:worker_threads'; @@ -100,7 +101,6 @@ export class WorkerShardingStrategy implements IShardingStrategy { .on('messageerror', (err) => { throw err; }) - // eslint-disable-next-line @typescript-eslint/no-misused-promises .on('message', async (payload: WorkerRecievePayload) => this.onMessage(worker, payload)); this.#workers.push(worker); @@ -128,7 +128,6 @@ export class WorkerShardingStrategy implements IShardingStrategy { // eslint-disable-next-line no-promise-executor-return const promise = new Promise((resolve) => this.connectPromises.set(shardId, resolve)); - // eslint-disable-next-line unicorn/require-post-message-target-origin worker.postMessage(payload); promises.push(promise); } @@ -153,7 +152,6 @@ export class WorkerShardingStrategy implements IShardingStrategy { // eslint-disable-next-line no-promise-executor-return, promise/prefer-await-to-then new Promise((resolve) => this.destroyPromises.set(shardId, resolve)).then(async () => worker.terminate()), ); - // eslint-disable-next-line unicorn/require-post-message-target-origin worker.postMessage(payload); } @@ -177,12 +175,10 @@ export class WorkerShardingStrategy implements IShardingStrategy { shardId, payload: data, }; - // eslint-disable-next-line unicorn/require-post-message-target-origin worker.postMessage(payload); } private async onMessage(worker: Worker, payload: WorkerRecievePayload) { - // eslint-disable-next-line default-case switch (payload.op) { case WorkerRecievePayloadOp.Connected: { const resolve = this.connectPromises.get(payload.shardId)!; @@ -199,7 +195,6 @@ export class WorkerShardingStrategy implements IShardingStrategy { } case WorkerRecievePayloadOp.Event: { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.manager.emit(payload.event, { ...payload.data, shardId: payload.shardId }); break; } @@ -211,7 +206,6 @@ export class WorkerShardingStrategy implements IShardingStrategy { nonce: payload.nonce, session, }; - // eslint-disable-next-line unicorn/require-post-message-target-origin worker.postMessage(response); break; } diff --git a/packages/ws/src/strategies/sharding/worker.ts b/packages/ws/src/strategies/sharding/worker.ts index be803e1aa..c76915024 100644 --- a/packages/ws/src/strategies/sharding/worker.ts +++ b/packages/ws/src/strategies/sharding/worker.ts @@ -58,9 +58,7 @@ parentPort! .on('messageerror', (err) => { throw err; }) - // eslint-disable-next-line @typescript-eslint/no-misused-promises .on('message', async (payload: WorkerSendPayload) => { - // eslint-disable-next-line default-case switch (payload.op) { case WorkerSendPayloadOp.Connect: { await connect(payload.shardId); diff --git a/packages/ws/src/utils/constants.ts b/packages/ws/src/utils/constants.ts index 8ccc9c6ed..715529932 100644 --- a/packages/ws/src/utils/constants.ts +++ b/packages/ws/src/utils/constants.ts @@ -21,10 +21,8 @@ export enum CompressionMethod { } const packageJson = readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf8'); -// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const Package = JSON.parse(packageJson); -// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access export const DefaultDeviceProperty = `@discordjs/ws ${Package.version}`; const getDefaultSessionStore = lazy(() => new Collection()); diff --git a/packages/ws/src/ws/WebSocketShard.ts b/packages/ws/src/ws/WebSocketShard.ts index e042f6b6a..27cbb2a24 100644 --- a/packages/ws/src/ws/WebSocketShard.ts +++ b/packages/ws/src/ws/WebSocketShard.ts @@ -384,7 +384,6 @@ export class WebSocketShard extends AsyncEventEmitter { return; } - // eslint-disable-next-line default-case switch (payload.op) { case GatewayOpcodes.Dispatch: { if (this.status === WebSocketShardStatus.Ready || this.status === WebSocketShardStatus.Resuming) {