Skip to content

Commit b124834

Browse files
committed
refactor: Always use curly braces.
1 parent 93de8c4 commit b124834

File tree

9 files changed

+42
-18
lines changed

9 files changed

+42
-18
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module.exports = {
99
'prettier/prettier': 'error',
1010
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
1111
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
12-
'func-call-spacing': 'warn',
12+
'func-call-spacing': 'error',
13+
'curly': 'error'
1314
},
1415
parserOptions: {
1516
parser: 'babel-eslint',

src/client.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,16 @@ process.on('unhandledRejection', console.error)
9898
*/
9999
client.on('message', msg => {
100100
// Don't process own messages.
101-
if (msg.author.id === msg.client.user.id) return
101+
if (msg.author.id === msg.client.user.id) {
102+
return
103+
}
102104

103105
client.jobs
104106
.filter(job => job.enabled)
105107
.forEach(job => {
106-
if (job.shouldExecute(msg)) job.run(msg)
108+
if (job.shouldExecute(msg)) {
109+
job.run(msg)
110+
}
107111
})
108112
})
109113

src/commands/jobs/disable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ module.exports = class JobsDisableCommand extends Command {
2828
}
2929

3030
hasPermission(msg) {
31-
if (msg.member.roles.some(role => ALLOWED_ROLES.includes(role.id)))
31+
if (msg.member.roles.some(role => ALLOWED_ROLES.includes(role.id))) {
3232
return true
33+
}
3334

3435
return ALLOWED_USERS.includes(msg.author.id)
3536
}

src/commands/jobs/enable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ module.exports = class JobsEnableCommand extends Command {
2828
}
2929

3030
hasPermission(msg) {
31-
if (msg.member.roles.some(role => ALLOWED_ROLES.includes(role.id)))
31+
if (msg.member.roles.some(role => ALLOWED_ROLES.includes(role.id))) {
3232
return true
33+
}
3334

3435
return ALLOWED_USERS.includes(msg.author.id)
3536
}

src/commands/jobs/info.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ module.exports = class JobsEnableCommand extends Command {
3030
}
3131

3232
hasPermission(msg) {
33-
if (msg.member.roles.some(role => ALLOWED_ROLES.includes(role.id)))
33+
if (msg.member.roles.some(role => ALLOWED_ROLES.includes(role.id))) {
3434
return true
35+
}
3536

3637
return ALLOWED_USERS.includes(msg.author.id)
3738
}
@@ -43,7 +44,9 @@ module.exports = class JobsEnableCommand extends Command {
4344
return msg.guild.roles.get(roleId).name
4445
})
4546

46-
if (!ignoredRoles.length) ignoredRoles = ['None']
47+
if (!ignoredRoles.length) {
48+
ignoredRoles = ['None']
49+
}
4750

4851
const embed = new RichEmbed()
4952
embed.setTitle('Job (' + job.name + ')')

src/commands/jobs/list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ module.exports = class JobsEnableCommand extends Command {
2323
}
2424

2525
hasPermission(msg) {
26-
if (msg.member.roles.some(role => ALLOWED_ROLES.includes(role.id)))
26+
if (msg.member.roles.some(role => ALLOWED_ROLES.includes(role.id))) {
2727
return true
28+
}
2829

2930
return ALLOWED_USERS.includes(msg.author.id)
3031
}

src/jobs/ban.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,23 @@ export default class BanJob extends Job {
3434
!banWords.some(word =>
3535
msg.content.toLowerCase().includes(word.toLowerCase())
3636
)
37-
)
37+
) {
3838
return false
39+
}
3940

4041
// We don't have permission to ban - bail.
41-
if (!msg.channel.permissionsFor(msg.client.user).has('BAN_MEMBERS'))
42+
if (!msg.channel.permissionsFor(msg.client.user).has('BAN_MEMBERS')) {
4243
return !!console.warn('[BanJob] Cannot ban - lacking permission.')
44+
}
4345

4446
const botMember = msg.guild.member(msg.client.user)
4547
const botHighestRole = botMember.highestRole.calculatedPosition
4648
const userHighestRole = msg.member.highestRole.calculatedPosition
4749

4850
// Our role is not high enough in the hierarchy to ban - bail.
49-
if (botHighestRole < userHighestRole)
51+
if (botHighestRole < userHighestRole) {
5052
return !!console.warn('[BanJob] Cannot ban - role too low.')
53+
}
5154

5255
return true
5356
}
@@ -57,10 +60,11 @@ export default class BanJob extends Job {
5760
channel => channel.name === this.config.logChannel.name
5861
)
5962

60-
if (!logChannel)
63+
if (!logChannel) {
6164
return console.warn(
6265
`WarnJob: Could not find channel with name ${this.config.logChannel.name}`
6366
)
67+
}
6468

6569
if (DEBUG_MODE) {
6670
return this.log(msg, logChannel)
@@ -73,11 +77,12 @@ export default class BanJob extends Job {
7377
}
7478

7579
log(msg, logChannel) {
76-
if (!logChannel)
80+
if (!logChannel) {
7781
return console.info(
7882
`Banned user: ${msg.author}`,
7983
`Due to message: ${msg.cleanContent}`
8084
)
85+
}
8186

8287
const embed = new RichEmbed()
8388
embed.setTitle('Banned User')

src/jobs/warn.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ export default class WarnJob extends Job {
3737
channel => channel.name === this.config.notifyChannel.name
3838
)
3939

40-
if (!notifyChannel)
40+
if (!notifyChannel) {
4141
return console.warn(
4242
`WarnJob: Could not find channel with name ${this.config.notifyChannel.name}`
4343
)
44+
}
4445

4546
notifyChannel.send(
4647
`${notifyRole} Suspicious user: ${msg.author} in channel ${msg.channel}`

src/lib/job.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ export default class Job {
1111
}
1212

1313
;['roles', 'users', 'channels', 'categories'].forEach(key => {
14-
if (!options.ignored[key]) options.ignored[key] = []
14+
if (!options.ignored[key]) {
15+
options.ignored[key] = []
16+
}
1517
})
1618

1719
if (!options.config) {
1820
options.config = {}
1921
}
2022

21-
if (typeof options.enabled === 'undefined') options.enabled = false
23+
if (typeof options.enabled === 'undefined') {
24+
options.enabled = false
25+
}
2226

2327
this.name = options.name
2428
this.config = options.config
@@ -29,13 +33,16 @@ export default class Job {
2933

3034
shouldExecute(msg) {
3135
if (msg.channel.type === 'dm') {
32-
if (this.guildOnly) return
36+
if (this.guildOnly) {
37+
return
38+
}
3339

3440
return true
3541
}
3642

37-
if (this.ignored.roles.length)
43+
if (this.ignored.roles.length) {
3844
return msg.member.roles.some(role => this.ignored.roles.includes(role.id))
45+
}
3946

4047
return true
4148
}

0 commit comments

Comments
 (0)