Skip to content

Commit

Permalink
Add arrow-parens eslint rule & fix inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Mar 13, 2017
1 parent ea24486 commit 68420ce
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"no-extra-parens": ["warn", "all", {
"nestedBinaryExpressions": false
}],
"arrow-parens": ["error", "as-needed", {
"requireForBlockBody": false
}],
"valid-jsdoc": ["error", {
"requireReturn": false,
"requireReturnDescription": false,
Expand Down
4 changes: 2 additions & 2 deletions src/client/rest/RESTMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class RESTMethods {
const messages = [];
(function sendChunk(list, index) {
const options = index === list.length ? { tts, embed } : { tts };
chan.send(list[index], options, index === list.length ? file : null).then((message) => {
chan.send(list[index], options, index === list.length ? file : null).then(message => {
messages.push(message);
if (index >= list.length - 1) return resolve(messages);
return sendChunk(list, ++index);
Expand Down Expand Up @@ -856,7 +856,7 @@ class RESTMethods {
acceptInvite(code) {
if (code.id) code = code.id;
return new Promise((resolve, reject) =>
this.rest.makeRequest('post', Constants.Endpoints.invite(code), true).then((res) => {
this.rest.makeRequest('post', Constants.Endpoints.invite(code), true).then(res => {
const handler = guild => {
if (guild.id === res.id) {
resolve(guild);
Expand Down
2 changes: 1 addition & 1 deletion src/client/voice/VoiceBroadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class VoiceBroadcast extends VolumeInterface {

let packetMatrix = {};

const getOpusPacket = (volume) => {
const getOpusPacket = volume => {
if (packetMatrix[volume]) return packetMatrix[volume];

const opusEncoder = this._encoders.get(volume);
Expand Down
6 changes: 3 additions & 3 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class Message {
get cleanContent() {
return this.content
.replace(/@(everyone|here)/g, '@\u200b$1')
.replace(/<@!?[0-9]+>/g, (input) => {
.replace(/<@!?[0-9]+>/g, input => {
const id = input.replace(/<|!|>|@/g, '');
if (this.channel.type === 'dm' || this.channel.type === 'group') {
return this.client.users.has(id) ? `@${this.client.users.get(id).username}` : input;
Expand All @@ -294,12 +294,12 @@ class Message {
return input;
}
})
.replace(/<#[0-9]+>/g, (input) => {
.replace(/<#[0-9]+>/g, input => {
const channel = this.client.channels.get(input.replace(/<|#|>/g, ''));
if (channel) return `#${channel.name}`;
return input;
})
.replace(/<@&[0-9]+>/g, (input) => {
.replace(/<@&[0-9]+>/g, input => {
if (this.channel.type === 'dm' || this.channel.type === 'group') return input;
const role = this.guild.roles.get(input.replace(/<|@|>|&/g, ''));
if (role) return `@${role.name}`;
Expand Down
64 changes: 32 additions & 32 deletions src/util/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,61 +87,61 @@ const Endpoints = exports.Endpoints = {
logout: `${API}/auth/logout`,
gateway: `${API}/gateway`,
botGateway: `${API}/gateway/bot`,
invite: (id) => `${API}/invite/${id}`,
inviteLink: (id) => `https://discord.gg/${id}`,
assets: (asset) => `${HOST}/assets/${asset}`,
invite: id => `${API}/invite/${id}`,
inviteLink: id => `https://discord.gg/${id}`,
assets: asset => `${HOST}/assets/${asset}`,
CDN: 'https://cdn.discordapp.com',

// users
user: (userID) => `${API}/users/${userID}`,
userChannels: (userID) => `${Endpoints.user(userID)}/channels`,
userProfile: (userID) => `${Endpoints.user(userID)}/profile`,
user: userID => `${API}/users/${userID}`,
userChannels: userID => `${Endpoints.user(userID)}/channels`,
userProfile: userID => `${Endpoints.user(userID)}/profile`,
avatar: (userID, avatar) => {
if (userID === '1') return avatar;
return `${Endpoints.CDN}/avatars/${userID}/${avatar}.${avatar.startsWith('a_') ? 'gif' : 'jpg'}?size=1024`;
},
me: `${API}/users/@me`,
meGuild: (guildID) => `${Endpoints.me}/guilds/${guildID}`,
meGuild: guildID => `${Endpoints.me}/guilds/${guildID}`,
meChannels: `${API}/users/@me/channels`,
meMentions: (limit, roles, everyone, guildID) =>
`users/@me/mentions?limit=${limit}&roles=${roles}&everyone=${everyone}${guildID ? `&guild_id=${guildID}` : ''}`,
relationships: (userID) => `${Endpoints.user(userID)}/relationships`,
note: (userID) => `${Endpoints.me}/notes/${userID}`,
relationships: userID => `${Endpoints.user(userID)}/relationships`,
note: userID => `${Endpoints.me}/notes/${userID}`,

voiceRegions: `${API}/voice/regions`,

// guilds
guilds: `${API}/guilds`,
guild: (guildID) => `${Endpoints.guilds}/${guildID}`,
guild: guildID => `${Endpoints.guilds}/${guildID}`,
guildIcon: (guildID, hash) => `${Endpoints.CDN}/icons/${guildID}/${hash}.jpg`,
guildSplash: (guildID, hash) => `${Endpoints.CDN}/splashes/${guildID}/${hash}.jpg`,
guildPrune: (guildID) => `${Endpoints.guild(guildID)}/prune`,
guildEmbed: (guildID) => `${Endpoints.guild(guildID)}/embed`,
guildInvites: (guildID) => `${Endpoints.guild(guildID)}/invites`,
guildRoles: (guildID) => `${Endpoints.guild(guildID)}/roles`,
guildPrune: guildID => `${Endpoints.guild(guildID)}/prune`,
guildEmbed: guildID => `${Endpoints.guild(guildID)}/embed`,
guildInvites: guildID => `${Endpoints.guild(guildID)}/invites`,
guildRoles: guildID => `${Endpoints.guild(guildID)}/roles`,
guildRole: (guildID, roleID) => `${Endpoints.guildRoles(guildID)}/${roleID}`,
guildBans: (guildID) => `${Endpoints.guild(guildID)}/bans`,
guildIntegrations: (guildID) => `${Endpoints.guild(guildID)}/integrations`,
guildMembers: (guildID) => `${Endpoints.guild(guildID)}/members`,
guildBans: guildID => `${Endpoints.guild(guildID)}/bans`,
guildIntegrations: guildID => `${Endpoints.guild(guildID)}/integrations`,
guildMembers: guildID => `${Endpoints.guild(guildID)}/members`,
guildMember: (guildID, memberID) => `${Endpoints.guildMembers(guildID)}/${memberID}`,
guildMemberRole: (guildID, memberID, roleID) => `${Endpoints.guildMember(guildID, memberID)}/roles/${roleID}`,
guildMemberNickname: (guildID) => `${Endpoints.guildMember(guildID, '@me')}/nick`,
guildChannels: (guildID) => `${Endpoints.guild(guildID)}/channels`,
guildEmojis: (guildID) => `${Endpoints.guild(guildID)}/emojis`,
guildMemberNickname: guildID => `${Endpoints.guildMember(guildID, '@me')}/nick`,
guildChannels: guildID => `${Endpoints.guild(guildID)}/channels`,
guildEmojis: guildID => `${Endpoints.guild(guildID)}/emojis`,
guildEmoji: (guildID, emojiID) => `${Endpoints.guildEmojis(guildID)}/${emojiID}`,
guildSearch: (guildID) => `${Endpoints.guild(guildID)}/messages/search`,
guildVoiceRegions: (guildID) => `${Endpoints.guild(guildID)}/regions`,
guildSearch: guildID => `${Endpoints.guild(guildID)}/messages/search`,
guildVoiceRegions: guildID => `${Endpoints.guild(guildID)}/regions`,

// channels
channels: `${API}/channels`,
channel: (channelID) => `${Endpoints.channels}/${channelID}`,
channelMessages: (channelID) => `${Endpoints.channel(channelID)}/messages`,
channelInvites: (channelID) => `${Endpoints.channel(channelID)}/invites`,
channelTyping: (channelID) => `${Endpoints.channel(channelID)}/typing`,
channelPermissions: (channelID) => `${Endpoints.channel(channelID)}/permissions`,
channel: channelID => `${Endpoints.channels}/${channelID}`,
channelMessages: channelID => `${Endpoints.channel(channelID)}/messages`,
channelInvites: channelID => `${Endpoints.channel(channelID)}/invites`,
channelTyping: channelID => `${Endpoints.channel(channelID)}/typing`,
channelPermissions: channelID => `${Endpoints.channel(channelID)}/permissions`,
channelMessage: (channelID, messageID) => `${Endpoints.channelMessages(channelID)}/${messageID}`,
channelWebhooks: (channelID) => `${Endpoints.channel(channelID)}/webhooks`,
channelSearch: (channelID) => `${Endpoints.channelMessages(channelID)}/search`,
channelWebhooks: channelID => `${Endpoints.channel(channelID)}/webhooks`,
channelSearch: channelID => `${Endpoints.channelMessages(channelID)}/search`,

dmChannelRecipient: (channelID, recipientID) => `${Endpoints.channel(channelID)}/recipients/${recipientID}`,

Expand All @@ -160,11 +160,11 @@ const Endpoints = exports.Endpoints = {
webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`,

// oauth
oauth2Application: (appID) => `${API}/oauth2/applications/${appID}`,
getApp: (id) => `${API}/oauth2/authorize?client_id=${id}`,
oauth2Application: appID => `${API}/oauth2/applications/${appID}`,
getApp: id => `${API}/oauth2/authorize?client_id=${id}`,

// emoji
emoji: (emojiID) => `${Endpoints.CDN}/emojis/${emojiID}.png`,
emoji: emojiID => `${Endpoints.CDN}/emojis/${emojiID}.png`,
};

/**
Expand Down

0 comments on commit 68420ce

Please sign in to comment.