mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
Add stricter/better ESLint config (#589)
* Add stricter/better ESLint config * Remove more unnecessary @returns
This commit is contained in:
committed by
Amish Shah
parent
2682c07bd8
commit
68acf37fd4
@@ -37,7 +37,7 @@ class Channel {
|
||||
|
||||
/**
|
||||
* Deletes the channel
|
||||
* @return {Promise<Channel>}
|
||||
* @returns {Promise<Channel>}
|
||||
* @example
|
||||
* // delete the channel
|
||||
* channel.delete()
|
||||
|
||||
@@ -53,7 +53,7 @@ class EvaluatedPermissions {
|
||||
}
|
||||
}
|
||||
|
||||
return ((this.permissions & permission) > 0);
|
||||
return (this.permissions & permission) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +54,11 @@ class GroupDMChannel extends Channel {
|
||||
}
|
||||
|
||||
equals(other) {
|
||||
const base = (
|
||||
other &&
|
||||
const base = other &&
|
||||
this.id === other.id &&
|
||||
this.name === other.name &&
|
||||
this.icon === other.icon &&
|
||||
this.owner.id === other.owner_id
|
||||
);
|
||||
this.owner.id === other.owner_id;
|
||||
|
||||
if (base) {
|
||||
const thisIDs = this.recipients.array().map(r => r.id);
|
||||
|
||||
@@ -123,10 +123,7 @@ class Guild {
|
||||
member.nickname = data.nick;
|
||||
}
|
||||
|
||||
const notSame = (
|
||||
member.nickname !== oldMember.nickname &&
|
||||
!arraysEqual(member._roles, oldMember._roles)
|
||||
);
|
||||
const notSame = member.nickname !== oldMember.nickname && !arraysEqual(member._roles, oldMember._roles);
|
||||
|
||||
if (this.client.ws.status === Constants.Status.READY && notSame) {
|
||||
/**
|
||||
@@ -183,28 +180,28 @@ class Guild {
|
||||
* @param {Guild} guild the guild to compare
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(data) {
|
||||
equals(guild) {
|
||||
let base =
|
||||
data &&
|
||||
this.id === data.id &&
|
||||
this.available === !data.unavailable &&
|
||||
this.splash === data.splash &&
|
||||
this.region === data.region &&
|
||||
this.name === data.name &&
|
||||
this.memberCount === data.member_count &&
|
||||
this.large === data.large &&
|
||||
this.icon === data.icon &&
|
||||
arraysEqual(this.features, data.features) &&
|
||||
this.ownerID === data.owner_id &&
|
||||
this.verificationLevel === data.verification_level &&
|
||||
this.embedEnabled === data.embed_enabled;
|
||||
guild &&
|
||||
this.id === guild.id &&
|
||||
this.available === !guild.unavailable &&
|
||||
this.splash === guild.splash &&
|
||||
this.region === guild.region &&
|
||||
this.name === guild.name &&
|
||||
this.memberCount === guild.member_count &&
|
||||
this.large === guild.large &&
|
||||
this.icon === guild.icon &&
|
||||
arraysEqual(this.features, guild.features) &&
|
||||
this.ownerID === guild.owner_id &&
|
||||
this.verificationLevel === guild.verification_level &&
|
||||
this.embedEnabled === guild.embed_enabled;
|
||||
|
||||
if (base) {
|
||||
if (this.embedChannel) {
|
||||
if (this.embedChannel.id !== data.embed_channel_id) {
|
||||
if (this.embedChannel.id !== guild.embed_channel_id) {
|
||||
base = false;
|
||||
}
|
||||
} else if (data.embed_channel_id) {
|
||||
} else if (guild.embed_channel_id) {
|
||||
base = false;
|
||||
}
|
||||
}
|
||||
@@ -228,8 +225,7 @@ class Guild {
|
||||
|
||||
/**
|
||||
* Sets up the Guild
|
||||
* @param {*} data
|
||||
* @returns {void}
|
||||
* @param {*} data the raw data of the guild
|
||||
* @private
|
||||
*/
|
||||
setup(data) {
|
||||
@@ -588,7 +584,8 @@ class Guild {
|
||||
throw new Error('already fetching guild members');
|
||||
}
|
||||
if (this.memberCount === this.members.size) {
|
||||
return resolve(this);
|
||||
resolve(this);
|
||||
return;
|
||||
}
|
||||
this._fetchWaiter = resolve;
|
||||
this.client.ws.send({
|
||||
@@ -627,7 +624,6 @@ class Guild {
|
||||
|
||||
/**
|
||||
* Syncs this guild (already done automatically every 30 seconds)
|
||||
* @returns {void}
|
||||
*/
|
||||
sync() {
|
||||
this.client.syncGuilds([this]);
|
||||
|
||||
@@ -65,20 +65,18 @@ class GuildChannel extends Channel {
|
||||
* @param {GuildChannel} channel the channel to compare this channel to
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(other) {
|
||||
let base = (
|
||||
other &&
|
||||
this.type === other.type &&
|
||||
this.topic === other.topic &&
|
||||
this.position === other.position &&
|
||||
this.name === other.name &&
|
||||
this.id === other.id
|
||||
);
|
||||
equals(channel) {
|
||||
let base = channel &&
|
||||
this.type === channel.type &&
|
||||
this.topic === channel.topic &&
|
||||
this.position === channel.position &&
|
||||
this.name === channel.name &&
|
||||
this.id === channel.id;
|
||||
|
||||
if (base) {
|
||||
if (other.permission_overwrites) {
|
||||
if (channel.permission_overwrites) {
|
||||
const thisIDSet = Array.from(this.permissionOverwrites.keys());
|
||||
const otherIDSet = other.permission_overwrites.map(overwrite => overwrite.id);
|
||||
const otherIDSet = channel.permission_overwrites.map(overwrite => overwrite.id);
|
||||
if (arraysEqual(thisIDSet, otherIDSet)) {
|
||||
base = true;
|
||||
} else {
|
||||
@@ -168,7 +166,7 @@ class GuildChannel extends Channel {
|
||||
/**
|
||||
* Overwrites the permissions for a user or role in this channel.
|
||||
* @param {Role|UserResolvable} userOrRole the user or role to update
|
||||
* @param {PermissionOverwriteOptions} config the configuration for the update
|
||||
* @param {PermissionOverwriteOptions} options the configuration for the update
|
||||
* @returns {Promise<null, Error>}
|
||||
* @example
|
||||
* // overwrite permissions for a message author
|
||||
@@ -205,11 +203,11 @@ class GuildChannel extends Channel {
|
||||
|
||||
for (const perm in options) {
|
||||
if (options[perm] === true) {
|
||||
payload.allow |= (Constants.PermissionFlags[perm] || 0);
|
||||
payload.allow |= Constants.PermissionFlags[perm] || 0;
|
||||
payload.deny &= ~(Constants.PermissionFlags[perm] || 0);
|
||||
} else if (options[perm] === false) {
|
||||
payload.allow &= ~(Constants.PermissionFlags[perm] || 0);
|
||||
payload.deny |= (Constants.PermissionFlags[perm] || 0);
|
||||
payload.deny |= Constants.PermissionFlags[perm] || 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ class Message {
|
||||
return new Date(this._editedTimestamp);
|
||||
}
|
||||
|
||||
patch(data) {
|
||||
patch(data) { // eslint-disable-line complexity
|
||||
if (data.author) {
|
||||
this.author = this.client.users.get(data.author.id);
|
||||
if (this.guild) {
|
||||
|
||||
@@ -212,7 +212,7 @@ class Role {
|
||||
}
|
||||
}
|
||||
|
||||
return ((this.permissions & permission) > 0);
|
||||
return (this.permissions & permission) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +229,7 @@ class Role {
|
||||
* @readonly
|
||||
*/
|
||||
get hexColor() {
|
||||
let col = (this.color).toString(16);
|
||||
let col = this.color.toString(16);
|
||||
while (col.length < 6) {
|
||||
col = `0${col}`;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class User {
|
||||
|
||||
/**
|
||||
* Deletes a DM Channel (if one exists) between the Client and the User. Resolves with the Channel if successful.
|
||||
* @return {Promise<DMChannel>}
|
||||
* @returns {Promise<DMChannel>}
|
||||
*/
|
||||
deleteDM() {
|
||||
return this.client.rest.methods.deleteChannel(this);
|
||||
@@ -93,14 +93,12 @@ class User {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(user) {
|
||||
let base = (
|
||||
user &&
|
||||
let base = user &&
|
||||
this.username === user.username &&
|
||||
this.id === user.id &&
|
||||
this.discriminator === user.discriminator &&
|
||||
this.avatar === user.avatar &&
|
||||
this.bot === Boolean(user.bot)
|
||||
);
|
||||
this.bot === Boolean(user.bot);
|
||||
|
||||
if (base) {
|
||||
if (user.status) {
|
||||
|
||||
@@ -59,7 +59,6 @@ class VoiceChannel extends GuildChannel {
|
||||
|
||||
/**
|
||||
* Leaves this voice channel
|
||||
* @returns {void}
|
||||
* @example
|
||||
* // leave a voice channel
|
||||
* voiceChannel.leave();
|
||||
|
||||
@@ -55,7 +55,7 @@ class MessageCollector extends EventEmitter {
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.ended = false;
|
||||
this.listener = (message => this.verify(message));
|
||||
this.listener = message => this.verify(message);
|
||||
this.channel.client.on('message', this.listener);
|
||||
/**
|
||||
* A collection of collected messages, mapped by message ID.
|
||||
@@ -70,7 +70,7 @@ class MessageCollector extends EventEmitter {
|
||||
/**
|
||||
* Verifies a message against the filter and options
|
||||
* @private
|
||||
* @param {Message} message
|
||||
* @param {Message} message the message
|
||||
* @returns {boolean}
|
||||
*/
|
||||
verify(message) {
|
||||
@@ -258,7 +258,6 @@ class TextBasedChannel {
|
||||
/**
|
||||
* Starts a typing indicator in the channel.
|
||||
* @param {number} [count] The number of times startTyping should be considered to have been called
|
||||
* @returns {void}
|
||||
* @example
|
||||
* // start typing in a channel
|
||||
* channel.startTyping();
|
||||
@@ -284,7 +283,6 @@ class TextBasedChannel {
|
||||
* The indicator will only stop if this is called as many times as startTyping().
|
||||
* <info>It can take a few seconds for the Client User to stop typing.</info>
|
||||
* @param {boolean} [force=false] whether or not to force the indicator to stop regardless of call count
|
||||
* @returns {void}
|
||||
* @example
|
||||
* // stop typing in a channel
|
||||
* channel.stopTyping();
|
||||
|
||||
Reference in New Issue
Block a user