summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-19 19:35:54 +0100
committerRory& <root@rory.gay>2025-12-19 19:35:54 +0100
commit3636d615db95f6d0bd2560a27131b541fa51aa22 (patch)
tree8acadc787b48a9218bc76eaad8864945db3e67d5
parentDEPRECATION: Move most select queries to object instead of string[] (diff)
downloadserver-ts-3636d615db95f6d0bd2560a27131b541fa51aa22.tar.xz
ESLint: warn for deprecated constructs
-rw-r--r--.lintstagedrc.mjs (renamed from .lintstagedrc.js)2
-rw-r--r--eslint.config.mjs16
-rw-r--r--scripts/schemaExclusions.json14
-rw-r--r--src/api/util/utility/RandomInviteID.ts6
-rw-r--r--src/util/util/Event.ts4
5 files changed, 32 insertions, 10 deletions
diff --git a/.lintstagedrc.js b/.lintstagedrc.mjs

index 76ea0b0a..f0ae6d5d 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 17e64dc8..eb865c2a 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 b2847670..64e2bbf0 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 0718a736..d7f2c629 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 a9f129c7..e2be9b19 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);