diff --git a/.lintstagedrc.js b/.lintstagedrc.mjs similarity index 89% rename from .lintstagedrc.js rename to .lintstagedrc.mjs index 76ea0b0a1..f0ae6d5d1 100644 --- a/.lintstagedrc.js +++ b/.lintstagedrc.mjs @@ -1,4 +1,4 @@ -module.exports = { +export default { "*.{j,t}s": ["eslint", "prettier --write"], "src/schemas/{*,**/*}.ts": [() => "tsc -b -v", () => "node scripts/schema.js", () => "node scripts/openapi.js"], }; diff --git a/eslint.config.mjs b/eslint.config.mjs index 17e64dc88..eb865c2ac 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,6 +5,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; import js from "@eslint/js"; import { FlatCompat } from "@eslint/eslintrc"; +import { defineConfig } from "eslint/config"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -14,12 +15,13 @@ const compat = new FlatCompat({ allConfig: js.configs.all, }); -export default [ +export default defineConfig([ { ignores: ["**/node_modules", "**/dist", "**/README.md", "**/COPYING", "**/scripts/", "**/assets", "**/extra/"], }, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), { + files: ["**/*.ts"], plugins: { "@typescript-eslint": typescriptEslint, }, @@ -30,6 +32,11 @@ export default [ }, parser: tsParser, + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + project: "./tsconfig.json", + }, }, rules: { @@ -38,6 +45,11 @@ export default [ "@typescript-eslint/no-var-requires": "off", // Sometimes requred by typeorm to resolve circular deps "@typescript-eslint/no-require-imports": "off", "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/no-deprecated": "warn", }, }, -]; + { + files: ["**/*.js", "**/*.cjs", "**/*.mjs"], + extends: typescriptEslint.configs?.disableTypeChecked ? [typescriptEslint.configs.disableTypeChecked] : [], + }, +]); diff --git a/scripts/schemaExclusions.json b/scripts/schemaExclusions.json index b28476707..64e2bbf00 100644 --- a/scripts/schemaExclusions.json +++ b/scripts/schemaExclusions.json @@ -1,6 +1,10 @@ { - "include": ["MessageInteractionSchema"], - "includeRe": ["^MessageComponentType\\..*"], + "include": [ + "MessageInteractionSchema" + ], + "includeRe": [ + "^MessageComponentType\\..*" + ], "manual": [ "DefaultSchema", "Schema", @@ -83,7 +87,9 @@ "^Job" ], "manualWarn": [], - "manualWarnRe": [".*<.*>$"], + "manualWarnRe": [ + ".*<.*>$" + ], "auto": [ { "value": "StringSchema", @@ -406,4 +412,4 @@ "reason": "Schema with only uppercase properties" } ] -} +} \ No newline at end of file diff --git a/src/api/util/utility/RandomInviteID.ts b/src/api/util/utility/RandomInviteID.ts index 0718a736e..d7f2c6296 100644 --- a/src/api/util/utility/RandomInviteID.ts +++ b/src/api/util/utility/RandomInviteID.ts @@ -49,7 +49,11 @@ export function snowflakeBasedInvite() { snowflake = snowflake / base; } - return str.substr(3, 8).split("").reverse().join(""); + return str + .slice(3, 3 + 8) + .split("") + .reverse() + .join(""); } export function randomUpperString(length: number = 10) { diff --git a/src/util/util/Event.ts b/src/util/util/Event.ts index a9f129c7b..e2be9b196 100644 --- a/src/util/util/Event.ts +++ b/src/util/util/Event.ts @@ -204,8 +204,8 @@ class UnixSocketListener { while (buffer.length >= 4) { const msgLen = buffer.readUInt32BE(0); if (buffer.length < 4 + msgLen) break; - const msgBuf = buffer.slice(4, 4 + msgLen); - buffer = buffer.slice(4 + msgLen); + const msgBuf = buffer.subarray(4, 4 + msgLen); + buffer = buffer.subarray(4 + msgLen); try { const payload = JSON.parse(msgBuf.toString()); this.eventEmitter.emit(payload.id, payload.event);