Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: require file extensions in file imports #10724

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/discord.js/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}
}
],
"import/extensions": ["error", "ignorePackages"],
"strict": ["error", "global"],
"no-await-in-loop": "warn",
"no-compare-neg-zero": "error",
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/scripts/generateRequires.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async function writeWebsocketHandlerImports() {
for (const file of (await readdir(handlersDirectory)).sort()) {
if (file === 'index.js') continue;

lines.push(` ['${file.slice(0, -3)}', require('./${file.slice(0, -3)}')],`);
lines.push(` ['${file.slice(0, -3)}', require('./${file}')],`);
}

lines.push(']);\n\nexports.PacketHandlers = PacketHandlers;\n');
Expand Down Expand Up @@ -38,7 +38,7 @@ async function writeClientActionImports() {

const actionName = file.slice(0, -3);

lines.push(` this.register(require('./${actionName}').${actionName}Action);`);
lines.push(` this.register(require('./${file}').${actionName}Action);`);
}

lines.push(' }\n');
Expand Down
6 changes: 3 additions & 3 deletions packages/discord.js/src/client/BaseClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
const EventEmitter = require('node:events');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v10');
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
const { Options } = require('../util/Options');
const { flatten } = require('../util/Util');
const { DiscordjsTypeError, ErrorCodes } = require('../errors/index.js');
const { Options } = require('../util/Options.js');
const { flatten } = require('../util/Util.js');

/**
* The base class for all clients.
Expand Down
52 changes: 26 additions & 26 deletions packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ const { Collection } = require('@discordjs/collection');
const { makeURLSearchParams } = require('@discordjs/rest');
const { WebSocketManager, WebSocketShardEvents, WebSocketShardStatus } = require('@discordjs/ws');
const { GatewayDispatchEvents, GatewayIntentBits, OAuth2Scopes, Routes } = require('discord-api-types/v10');
const { BaseClient } = require('./BaseClient');
const { ActionsManager } = require('./actions/ActionsManager');
const { ClientVoiceManager } = require('./voice/ClientVoiceManager');
const { PacketHandlers } = require('./websocket/handlers');
const { DiscordjsError, DiscordjsTypeError, ErrorCodes } = require('../errors');
const { BaseGuildEmojiManager } = require('../managers/BaseGuildEmojiManager');
const { ChannelManager } = require('../managers/ChannelManager');
const { GuildManager } = require('../managers/GuildManager');
const { UserManager } = require('../managers/UserManager');
const { ShardClientUtil } = require('../sharding/ShardClientUtil');
const { ClientPresence } = require('../structures/ClientPresence');
const { GuildPreview } = require('../structures/GuildPreview');
const { GuildTemplate } = require('../structures/GuildTemplate');
const { Invite } = require('../structures/Invite');
const { Sticker } = require('../structures/Sticker');
const { StickerPack } = require('../structures/StickerPack');
const { VoiceRegion } = require('../structures/VoiceRegion');
const { Webhook } = require('../structures/Webhook');
const { Widget } = require('../structures/Widget');
const { resolveInviteCode, resolveGuildTemplateCode } = require('../util/DataResolver');
const { Events } = require('../util/Events');
const { IntentsBitField } = require('../util/IntentsBitField');
const { Options } = require('../util/Options');
const { PermissionsBitField } = require('../util/PermissionsBitField');
const { Status } = require('../util/Status');
const { Sweepers } = require('../util/Sweepers');
const { BaseClient } = require('./BaseClient.js');
const { ActionsManager } = require('./actions/ActionsManager.js');
const { ClientVoiceManager } = require('./voice/ClientVoiceManager.js');
const { PacketHandlers } = require('./websocket/handlers/index.js');
const { DiscordjsError, DiscordjsTypeError, ErrorCodes } = require('../errors/index.js');
const { BaseGuildEmojiManager } = require('../managers/BaseGuildEmojiManager.js');
const { ChannelManager } = require('../managers/ChannelManager.js');
const { GuildManager } = require('../managers/GuildManager.js');
const { UserManager } = require('../managers/UserManager.js');
const { ShardClientUtil } = require('../sharding/ShardClientUtil.js');
const { ClientPresence } = require('../structures/ClientPresence.js');
const { GuildPreview } = require('../structures/GuildPreview.js');
const { GuildTemplate } = require('../structures/GuildTemplate.js');
const { Invite } = require('../structures/Invite.js');
const { Sticker } = require('../structures/Sticker.js');
const { StickerPack } = require('../structures/StickerPack.js');
const { VoiceRegion } = require('../structures/VoiceRegion.js');
const { Webhook } = require('../structures/Webhook.js');
const { Widget } = require('../structures/Widget.js');
const { resolveInviteCode, resolveGuildTemplateCode } = require('../util/DataResolver.js');
const { Events } = require('../util/Events.js');
const { IntentsBitField } = require('../util/IntentsBitField.js');
const { Options } = require('../util/Options.js');
const { PermissionsBitField } = require('../util/PermissionsBitField.js');
const { Status } = require('../util/Status.js');
const { Sweepers } = require('../util/Sweepers.js');

const WaitingForGuildEvents = [GatewayDispatchEvents.GuildCreate, GatewayDispatchEvents.GuildDelete];
const BeforeReadyWhitelist = [
Expand Down
8 changes: 4 additions & 4 deletions packages/discord.js/src/client/WebhookClient.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const { BaseClient } = require('./BaseClient');
const { DiscordjsError, ErrorCodes } = require('../errors');
const { Webhook } = require('../structures/Webhook');
const { parseWebhookURL } = require('../util/Util');
const { BaseClient } = require('./BaseClient.js');
const { DiscordjsError, ErrorCodes } = require('../errors/index.js');
const { Webhook } = require('../structures/Webhook.js');
const { parseWebhookURL } = require('../util/Util.js');

/**
* The webhook client.
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/client/actions/Action.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { Partials } = require('../../util/Partials');
const { Partials } = require('../../util/Partials.js');

/*
Expand Down
80 changes: 39 additions & 41 deletions packages/discord.js/src/client/actions/ActionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,45 @@ class ActionsManager {
constructor(client) {
this.client = client;

this.register(require('./ChannelCreate').ChannelCreateAction);
this.register(require('./ChannelDelete').ChannelDeleteAction);
this.register(require('./ChannelUpdate').ChannelUpdateAction);
this.register(require('./GuildChannelsPositionUpdate').GuildChannelsPositionUpdateAction);
this.register(require('./GuildEmojiCreate').GuildEmojiCreateAction);
this.register(require('./GuildEmojiDelete').GuildEmojiDeleteAction);
this.register(require('./GuildEmojiUpdate').GuildEmojiUpdateAction);
this.register(require('./GuildEmojiUpdate').GuildEmojiUpdateAction);
this.register(require('./GuildEmojisUpdate').GuildEmojisUpdateAction);
this.register(require('./GuildMemberRemove').GuildMemberRemoveAction);
this.register(require('./GuildMemberUpdate').GuildMemberUpdateAction);
this.register(require('./GuildRoleCreate').GuildRoleCreateAction);
this.register(require('./GuildRoleDelete').GuildRoleDeleteAction);
this.register(require('./GuildRolesPositionUpdate').GuildRolesPositionUpdateAction);
this.register(require('./GuildScheduledEventDelete').GuildScheduledEventDeleteAction);
this.register(require('./GuildScheduledEventUserAdd').GuildScheduledEventUserAddAction);
this.register(require('./GuildScheduledEventUserRemove').GuildScheduledEventUserRemoveAction);
this.register(require('./GuildStickerCreate').GuildStickerCreateAction);
this.register(require('./GuildStickerDelete').GuildStickerDeleteAction);
this.register(require('./GuildStickerUpdate').GuildStickerUpdateAction);
this.register(require('./GuildStickerUpdate').GuildStickerUpdateAction);
this.register(require('./GuildStickersUpdate').GuildStickersUpdateAction);
this.register(require('./GuildUpdate').GuildUpdateAction);
this.register(require('./InteractionCreate').InteractionCreateAction);
this.register(require('./MessageCreate').MessageCreateAction);
this.register(require('./MessageDelete').MessageDeleteAction);
this.register(require('./MessageDeleteBulk').MessageDeleteBulkAction);
this.register(require('./MessagePollVoteAdd').MessagePollVoteAddAction);
this.register(require('./MessagePollVoteRemove').MessagePollVoteRemoveAction);
this.register(require('./MessageReactionAdd').MessageReactionAddAction);
this.register(require('./MessageReactionRemove').MessageReactionRemoveAction);
this.register(require('./MessageReactionRemoveAll').MessageReactionRemoveAllAction);
this.register(require('./MessageReactionRemoveEmoji').MessageReactionRemoveEmojiAction);
this.register(require('./MessageUpdate').MessageUpdateAction);
this.register(require('./StageInstanceCreate').StageInstanceCreateAction);
this.register(require('./StageInstanceDelete').StageInstanceDeleteAction);
this.register(require('./StageInstanceUpdate').StageInstanceUpdateAction);
this.register(require('./ThreadCreate').ThreadCreateAction);
this.register(require('./ThreadMembersUpdate').ThreadMembersUpdateAction);
this.register(require('./TypingStart').TypingStartAction);
this.register(require('./UserUpdate').UserUpdateAction);
this.register(require('./ChannelCreate.js').ChannelCreateAction);
this.register(require('./ChannelDelete.js').ChannelDeleteAction);
this.register(require('./ChannelUpdate.js').ChannelUpdateAction);
this.register(require('./GuildChannelsPositionUpdate.js').GuildChannelsPositionUpdateAction);
this.register(require('./GuildEmojiCreate.js').GuildEmojiCreateAction);
this.register(require('./GuildEmojiDelete.js').GuildEmojiDeleteAction);
this.register(require('./GuildEmojiUpdate.js').GuildEmojiUpdateAction);
this.register(require('./GuildEmojisUpdate.js').GuildEmojisUpdateAction);
this.register(require('./GuildMemberRemove.js').GuildMemberRemoveAction);
this.register(require('./GuildMemberUpdate.js').GuildMemberUpdateAction);
this.register(require('./GuildRoleCreate.js').GuildRoleCreateAction);
this.register(require('./GuildRoleDelete.js').GuildRoleDeleteAction);
this.register(require('./GuildRolesPositionUpdate.js').GuildRolesPositionUpdateAction);
this.register(require('./GuildScheduledEventDelete.js').GuildScheduledEventDeleteAction);
this.register(require('./GuildScheduledEventUserAdd.js').GuildScheduledEventUserAddAction);
this.register(require('./GuildScheduledEventUserRemove.js').GuildScheduledEventUserRemoveAction);
this.register(require('./GuildStickerCreate.js').GuildStickerCreateAction);
this.register(require('./GuildStickerDelete.js').GuildStickerDeleteAction);
this.register(require('./GuildStickerUpdate.js').GuildStickerUpdateAction);
this.register(require('./GuildStickersUpdate.js').GuildStickersUpdateAction);
this.register(require('./GuildUpdate.js').GuildUpdateAction);
this.register(require('./InteractionCreate.js').InteractionCreateAction);
this.register(require('./MessageCreate.js').MessageCreateAction);
this.register(require('./MessageDelete.js').MessageDeleteAction);
this.register(require('./MessageDeleteBulk.js').MessageDeleteBulkAction);
this.register(require('./MessagePollVoteAdd.js').MessagePollVoteAddAction);
this.register(require('./MessagePollVoteRemove.js').MessagePollVoteRemoveAction);
this.register(require('./MessageReactionAdd.js').MessageReactionAddAction);
this.register(require('./MessageReactionRemove.js').MessageReactionRemoveAction);
this.register(require('./MessageReactionRemoveAll.js').MessageReactionRemoveAllAction);
this.register(require('./MessageReactionRemoveEmoji.js').MessageReactionRemoveEmojiAction);
this.register(require('./MessageUpdate.js').MessageUpdateAction);
this.register(require('./StageInstanceCreate.js').StageInstanceCreateAction);
this.register(require('./StageInstanceDelete.js').StageInstanceDeleteAction);
this.register(require('./StageInstanceUpdate.js').StageInstanceUpdateAction);
this.register(require('./ThreadCreate.js').ThreadCreateAction);
this.register(require('./ThreadMembersUpdate.js').ThreadMembersUpdateAction);
this.register(require('./TypingStart.js').TypingStartAction);
this.register(require('./UserUpdate.js').UserUpdateAction);
}

register(Action) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/ChannelCreate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class ChannelCreateAction extends Action {
handle(data) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/ChannelDelete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class ChannelDeleteAction extends Action {
handle(data) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/ChannelUpdate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { createChannel } = require('../../util/Channels');
const { Action } = require('./Action.js');
const { createChannel } = require('../../util/Channels.js');

class ChannelUpdateAction extends Action {
handle(data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { Action } = require('./Action');
const { Action } = require('./Action.js');

class GuildChannelsPositionUpdateAction extends Action {
handle(data) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/GuildEmojiCreate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildEmojiCreateAction extends Action {
handle(guild, createdEmoji) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/GuildEmojiDelete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildEmojiDeleteAction extends Action {
handle(emoji) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/GuildEmojiUpdate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildEmojiUpdateAction extends Action {
handle(current, data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { Action } = require('./Action');
const { Action } = require('./Action.js');

class GuildEmojisUpdateAction extends Action {
handle(data) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/GuildMemberRemove.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildMemberRemoveAction extends Action {
handle(data) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/GuildMemberUpdate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildMemberUpdateAction extends Action {
handle(data) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/GuildRoleCreate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildRoleCreateAction extends Action {
handle(data) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/client/actions/GuildRoleDelete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildRoleDeleteAction extends Action {
handle(data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { Action } = require('./Action');
const { Action } = require('./Action.js');

class GuildRolesPositionUpdateAction extends Action {
handle(data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildScheduledEventDeleteAction extends Action {
handle(data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildScheduledEventUserAddAction extends Action {
handle(data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildScheduledEventUserRemoveAction extends Action {
handle(data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildStickerCreateAction extends Action {
handle(guild, createdSticker) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildStickerDeleteAction extends Action {
handle(sticker) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Action } = require('./Action');
const { Events } = require('../../util/Events');
const { Action } = require('./Action.js');
const { Events } = require('../../util/Events.js');

class GuildStickerUpdateAction extends Action {
handle(current, data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { Action } = require('./Action');
const { Action } = require('./Action.js');

class GuildStickersUpdateAction extends Action {
handle(data) {
Expand Down
Loading
Loading