Skip to content

Commit

Permalink
feat: add eslint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx authored and sdanialraza committed Dec 8, 2024
1 parent fb6f7cd commit c0f24ea
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 42 deletions.
14 changes: 14 additions & 0 deletions packages/discord.js/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,23 @@
"name": "clearInterval",
"message": "Import clearInterval from `node:timers` instead"
}
],

"no-restricted-syntax": [
"error",
{
"selector": "AssignmentExpression[left.object.name='module'][left.property.name='exports']",
"message": "Use named exports instead of module.exports"
}
]
}
},
{
"files": ["src/client/websocket/handlers/*.js"],
"rules": {
"no-restricted-syntax": "off"
}
},
{
"files": ["typings/*.ts", "scripts/*.mjs"],
"parser": "@typescript-eslint/parser",
Expand Down
8 changes: 3 additions & 5 deletions packages/discord.js/src/errors/DJSError.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ function message(code, args) {
return String(...args);
}

module.exports = {
DiscordjsError: makeDiscordjsError(Error),
DiscordjsTypeError: makeDiscordjsError(TypeError),
DiscordjsRangeError: makeDiscordjsError(RangeError),
};
exports.DiscordjsError = makeDiscordjsError(Error);
exports.DiscordjsTypeError = makeDiscordjsError(TypeError);
exports.DiscordjsRangeError = makeDiscordjsError(RangeError);
4 changes: 3 additions & 1 deletion packages/discord.js/src/errors/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

module.exports = require('./DJSError');
exports.DiscordjsError = require('./DJSError').DiscordjsError;
exports.DiscordjsTypeError = require('./DJSError').DiscordjsTypeError;
exports.DiscordjsRangeError = require('./DJSError').DiscordjsRangeError;
exports.ErrorCodes = require('./ErrorCodes').ErrorCodes;
exports.Messages = require('./Messages').Messages;
12 changes: 5 additions & 7 deletions packages/discord.js/src/util/Channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,8 @@ function transformGuildDefaultReaction(defaultReaction) {
};
}

module.exports = {
createChannel,
transformAPIGuildForumTag,
transformGuildForumTag,
transformAPIGuildDefaultReaction,
transformGuildDefaultReaction,
};
exports.createChannel = createChannel;
exports.transformAPIGuildForumTag = transformAPIGuildForumTag;
exports.transformGuildForumTag = transformGuildForumTag;
exports.transformAPIGuildDefaultReaction = transformAPIGuildDefaultReaction;
exports.transformGuildDefaultReaction = transformGuildDefaultReaction;
3 changes: 2 additions & 1 deletion packages/discord.js/src/util/Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ function createComponentBuilder(data) {
}
}

module.exports = { createComponent, createComponentBuilder };
exports.createComponent = createComponent;
exports.createComponentBuilder = createComponentBuilder;

const { ActionRow } = require('../structures/ActionRow');
const { ActionRowBuilder } = require('../structures/ActionRowBuilder');
Expand Down
7 changes: 6 additions & 1 deletion packages/discord.js/src/util/DataResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,9 @@ async function resolveImage(image) {
return resolveBase64(file.data);
}

module.exports = { resolveCode, resolveInviteCode, resolveGuildTemplateCode, resolveImage, resolveBase64, resolveFile };
exports.resolveCode = resolveCode;
exports.resolveInviteCode = resolveInviteCode;
exports.resolveGuildTemplateCode = resolveGuildTemplateCode;
exports.resolveImage = resolveImage;
exports.resolveBase64 = resolveBase64;
exports.resolveFile = resolveFile;
2 changes: 1 addition & 1 deletion packages/discord.js/src/util/Enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ function createEnum(keys) {
return obj;
}

module.exports = { createEnum };
exports.createEnum = createEnum;
10 changes: 4 additions & 6 deletions packages/discord.js/src/util/Transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ function _transformGuildScheduledEventRecurrenceRule(recurrenceRule) {
};
}

module.exports = {
toSnakeCase,
_transformAPIAutoModerationAction,
_transformAPIMessageInteractionMetadata,
_transformGuildScheduledEventRecurrenceRule,
};
exports.toSnakeCase = toSnakeCase;
exports._transformAPIAutoModerationAction = _transformAPIAutoModerationAction;
exports._transformAPIMessageInteractionMetadata = _transformAPIMessageInteractionMetadata;
exports._transformGuildScheduledEventRecurrenceRule = _transformGuildScheduledEventRecurrenceRule;
38 changes: 18 additions & 20 deletions packages/discord.js/src/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,26 +499,24 @@ function resolveSKUId(resolvable) {
return null;
}

module.exports = {
flatten,
fetchRecommendedShardCount,
parseEmoji,
resolvePartialEmoji,
makeError,
makePlainError,
getSortableGroupTypes,
moveElementInArray,
verifyString,
resolveColor,
discordSort,
setPosition,
basename,
cleanContent,
cleanCodeBlockContent,
parseWebhookURL,
transformResolved,
resolveSKUId,
};
exports.flatten = flatten;
exports.fetchRecommendedShardCount = fetchRecommendedShardCount;
exports.parseEmoji = parseEmoji;
exports.resolvePartialEmoji = resolvePartialEmoji;
exports.makeError = makeError;
exports.makePlainError = makePlainError;
exports.getSortableGroupTypes = getSortableGroupTypes;
exports.moveElementInArray = moveElementInArray;
exports.verifyString = verifyString;
exports.resolveColor = resolveColor;
exports.discordSort = discordSort;
exports.setPosition = setPosition;
exports.basename = basename;
exports.cleanContent = cleanContent;
exports.cleanCodeBlockContent = cleanCodeBlockContent;
exports.parseWebhookURL = parseWebhookURL;
exports.transformResolved = transformResolved;
exports.resolveSKUId = resolveSKUId;

// Fixes Circular
const { Attachment } = require('../structures/Attachment');
Expand Down

0 comments on commit c0f24ea

Please sign in to comment.