From 53efb915b55775b38fcf1e71dc29583dfe9ab085 Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sun, 6 Aug 2023 12:57:07 -0400 Subject: [PATCH] Lint fixes and format as part of the pre-commit --- .eslintrc.yml | 9 +++------ .husky/pre-commit | 1 + src/command.ts | 2 +- src/components/buzzwords.ts | 6 +++--- src/components/forum-channels.ts | 4 ++-- src/components/inspect.ts | 6 ++++-- src/components/modmail.ts | 6 +++--- src/infra/member-tracker.ts | 1 - 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 3672c11e..fd2325bc 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -32,9 +32,6 @@ rules: semi: - error - always - quotes: - - error - - double no-unused-vars: - off no-constant-condition: @@ -49,9 +46,6 @@ rules: object-curly-spacing: - error - always - space-in-parens: - - error - - never comma-spacing: - error computed-property-spacing: @@ -65,6 +59,9 @@ rules: semi-style: - error - last + prefer-const: + - error + - destructuring: all "prettier/prettier": "error" "@typescript-eslint/no-unused-vars": - warn diff --git a/.husky/pre-commit b/.husky/pre-commit index a830d634..381e65ec 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,5 +2,6 @@ . "$(dirname -- "$0")/_/husky.sh" #tsc --noEmit +npm run format npx lint-staged #npm test diff --git a/src/command.ts b/src/command.ts index f7935725..31ff31ec 100644 --- a/src/command.ts +++ b/src/command.ts @@ -295,8 +295,8 @@ export class TextBasedCommand extends Command { this.member = reply_object.member; this.user = reply_object.author; } + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition } else if (args[0] == "c") { - // eslint-disable-line @typescript-eslint/no-unnecessary-condition // construct from copy, used for edit const [_, command, name, reply_object] = args; this.name = name; diff --git a/src/components/buzzwords.ts b/src/components/buzzwords.ts index 3aba74d8..eb088cf4 100644 --- a/src/components/buzzwords.ts +++ b/src/components/buzzwords.ts @@ -187,8 +187,8 @@ export default class Buzzwords extends BotComponent { } override async on_ready() { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (ENABLED) { - // eslint-disable-line @typescript-eslint/no-unnecessary-condition //await this.update_database(); //this.timeout = setTimeout(() => { // this.update_database().catch(critical_error); @@ -248,8 +248,8 @@ export default class Buzzwords extends BotComponent { } async updateRolesSingle(member: Discord.GuildMember) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (ENABLED) { - // eslint-disable-line @typescript-eslint/no-unnecessary-condition // TODO: If we ever do this joke again, cache the quantiles from reflowRoles to save an expensive database // query and computation here const entries = await this.wheatley.database.buzzword_scoreboard.find().toArray(); @@ -448,8 +448,8 @@ export default class Buzzwords extends BotComponent { }); } // check the message for buzzwords + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (ENABLED) { - // eslint-disable-line @typescript-eslint/no-unnecessary-condition if (!this.slowmode.has(message.author.id)) { let total_score = 0; let count = 0; diff --git a/src/components/forum-channels.ts b/src/components/forum-channels.ts index 139bd5eb..ccdb9524 100644 --- a/src/components/forum-channels.ts +++ b/src/components/forum-channels.ts @@ -211,8 +211,8 @@ export default class ForumChannels extends BotComponent { colors.red, "When your question is answered use **`!solved`** to " + "mark the question as resolved.\n\nRemember to ask __specific questions__, provide " + - "__necessary details__, and reduce your question to its __simplest form__. For tips on how " + - "to ask a good question run `!howto ask`.", + "__necessary details__, and reduce your question to its __simplest form__. For tips " + + "on how to ask a good question run `!howto ask`.", ), ], }); diff --git a/src/components/inspect.ts b/src/components/inspect.ts index 50491ce5..a7c64abc 100644 --- a/src/components/inspect.ts +++ b/src/components/inspect.ts @@ -56,7 +56,8 @@ export default class Inspect extends BotComponent { "Attachments: " + JSON.stringify( message.attachments.map( - // This looks silly, but it is the best way I can think of to call all the getters and re-package + // This looks silly, but it is the best way I can think of to call all the getters and + // re-package ({ contentType, description, @@ -96,7 +97,8 @@ export default class Inspect extends BotComponent { "Embeds: " + JSON.stringify( message.embeds.map( - // This looks silly, but it is the best way I can think of to call all the getters and re-package + // This looks silly, but it is the best way I can think of to call all the getters and + // re-package ({ author, color, diff --git a/src/components/modmail.ts b/src/components/modmail.ts index 5650024d..dc2cc80e 100644 --- a/src/components/modmail.ts +++ b/src/components/modmail.ts @@ -118,9 +118,9 @@ export default class Modmail extends BotComponent { create_embed( "Modmail", "If you have a **moderation** or **administration** related issue you " + - "can reach out to the staff team by pressing the modmail thread button below.\n\nBecause, in " + - "our experience, a surprising number of users also can't read, there is also a monkey " + - "button.", + "can reach out to the staff team by pressing the modmail thread button below.\n\n" + + "Because, in our experience, a surprising number of users also can't read, there is also " + + "a monkey button.", ), ], components: [row], diff --git a/src/infra/member-tracker.ts b/src/infra/member-tracker.ts index 883323ca..588efbb0 100644 --- a/src/infra/member-tracker.ts +++ b/src/infra/member-tracker.ts @@ -68,7 +68,6 @@ export class MemberTracker { // -- ping/link maps -- for (const map of [this.ping_map, this.link_map]) { for (let [k, v] of map) { - /* eslint-disable-line prefer-const */ v = v.filter(m => now - m.createdTimestamp <= LOG_DURATION); if (v.length == 0) { this.ping_map.delete(k);