From 45b21835b20bde965e6a76e681ac2f0dc64ee207 Mon Sep 17 00:00:00 2001 From: Taken Date: Fri, 19 Jan 2024 13:16:56 +0100 Subject: [PATCH] Formatting and linting --- .eslintrc.js | 92 +++++++++++++++--------------------- .prettierrc.js | 4 +- src/commands/timeout.ts | 18 +++---- src/utils/Hypixel/bedwars.ts | 18 +++---- src/utils/Hypixel/hypixel.ts | 14 +++--- 5 files changed, 64 insertions(+), 82 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 87edc61..fdf3994 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,75 +1,59 @@ module.exports = { - "env": { - "node": true, - "es2021": true, - "browser": true + env: { + node: true, + es2021: true, + browser: true, }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [ + extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], + overrides: [ { - "env": { - "node": true + env: { + node: true, }, - "files": [ - ".eslintrc.{js,cjs}" - ], - "parserOptions": { - "sourceType": "script" - } - } + files: [".eslintrc.{js,cjs}"], + parserOptions: { + sourceType: "script", + }, + }, ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "indent": [ - "error", - 4 - ], - "linebreak-style": [ - "error", - "windows" - ], - "quotes": [ - "warn", - "double" - ], - "semi": [ - "error", - "never" - ], + plugins: ["@typescript-eslint"], + rules: { + indent: ["error", 4, { SwitchCase: 1 }], + "linebreak-style": ["error", "windows"], + quotes: ["warn", "double"], + semi: ["error", "never"], "no-unused-vars": "off", "prefer-const": "warn", "no-var": "error", - "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }], + "no-multiple-empty-lines": ["error", { max: 2, maxEOF: 1, maxBOF: 0 }], "no-lonely-if": "error", "no-empty-function": "error", "no-inline-comments": "error", "no-trailing-spaces": ["error"], - "arrow-spacing": ["warn", { "before": true, "after": true }], - "space-before-function-paren": ["error", { - "anonymous": "never", - "named": "never", - "asyncArrow": "always" - }], + "arrow-spacing": ["warn", { before: true, after: true }], + "space-before-function-paren": [ + "error", + { + anonymous: "never", + named: "never", + asyncArrow: "always", + }, + ], "comma-spacing": "error", "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-unused-vars": [ "warn", { - "vars": "all", - "args": "after-used", - "ignoreRestSiblings": false - } + vars: "all", + args: "after-used", + ignoreRestSiblings: false, + }, ], - } + }, } diff --git a/.prettierrc.js b/.prettierrc.js index 3d0ed42..9257b96 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -11,7 +11,7 @@ const config = { bracketSpacing: true, arrowParens: "avoid", parser: "typescript", - endOfLine: "crlf" + endOfLine: "crlf", } -module.exports = config \ No newline at end of file +module.exports = config diff --git a/src/commands/timeout.ts b/src/commands/timeout.ts index 1f589ee..ccad633 100644 --- a/src/commands/timeout.ts +++ b/src/commands/timeout.ts @@ -123,33 +123,33 @@ export = { if (target.isCommunicationDisabled()) { if (time === 0) { title = "Timeout Removed" - ;(description = + description = "Removed timeout of " + userMention(target.id) + " for " + - reason), - (timeouttime = null) + reason + timeouttime = null } else { title = "Timeout Updated" - ;(description = + description = "Updated timeout of " + userMention(target.id) + " to " + prettyTime + " for " + - reason), - (timeouttime = time) + reason + timeouttime = time } } else { title = "Member Timed Out" - ;(description = + description = "Timed out " + userMention(target.id) + " for " + prettyTime + " for " + - reason), - (timeouttime = time) + reason + timeouttime = time } await target.timeout(timeouttime, reason) diff --git a/src/utils/Hypixel/bedwars.ts b/src/utils/Hypixel/bedwars.ts index 03d5657..4a0bc24 100644 --- a/src/utils/Hypixel/bedwars.ts +++ b/src/utils/Hypixel/bedwars.ts @@ -10,14 +10,14 @@ function getExpForLevel(level: number): number { } switch (respectedLevel) { - case 1: - return 500 - case 2: - return 1000 - case 3: - return 2000 - case 4: - return 3500 + case 1: + return 500 + case 2: + return 1000 + case 3: + return 2000 + case 4: + return 3500 } return 5000 } @@ -31,7 +31,7 @@ function getLevelRespectingPrestige(level: number): number { } const EASY_LEVELS = 4 -const EASY_LEVELS_XP = 7000 +const EASY_LEVELS_XP = 7004 const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP const LEVELS_PER_PRESTIGE = 100 const HIGHEST_PRESTIGE = 50 diff --git a/src/utils/Hypixel/hypixel.ts b/src/utils/Hypixel/hypixel.ts index 93465d3..043c5ea 100644 --- a/src/utils/Hypixel/hypixel.ts +++ b/src/utils/Hypixel/hypixel.ts @@ -6,16 +6,14 @@ const GROWTH = 2500 const HALF_GROWTH = 0.5 * GROWTH const REVERSE_PQ_PREFIX = -(BASE - 0.5 * GROWTH) / GROWTH const REVERSE_CONST = REVERSE_PQ_PREFIX * REVERSE_PQ_PREFIX -const GROWTH_DIVIDES_2 = 2 / GROWTH +const GROWTHDIV2 = 2 / GROWTH function getLevel(exp: number): number { - return exp <= 1 - ? 1 - : Math.floor( - 1 + - REVERSE_PQ_PREFIX + - Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp), - ) + if (exp <= 1) return 1 + + return Math.floor( + 1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTHDIV2 * exp), + ) } function hypixelLevel(exp: number): number {