From 07ec5131b78d175060fc7d5fcb110829ff8d04e2 Mon Sep 17 00:00:00 2001 From: ryan-0324 <77452312+ryan-0324@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:07:47 -0400 Subject: [PATCH] refactor: misc. changes --- eslint.config.mjs | 4 ++-- packages/discord-types/eslint.config.mjs | 6 ++--- src/globals.d.ts | 23 +++++++++++++++++++ .../memberCount/OnlineMemberCountStore.ts | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index eac0e4818..a4554372e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -60,7 +60,7 @@ export default tseslint.config( "@stylistic/jsx-closing-bracket-location": "error", "@stylistic/jsx-closing-tag-location": "error", "@stylistic/jsx-curly-brace-presence": ["error", { propElementValues: "always" }], - "@stylistic/jsx-curly-spacing": "error", + "@stylistic/jsx-curly-spacing": ["error", { children: true }], "@stylistic/jsx-equals-spacing": "error", "@stylistic/jsx-first-prop-new-line": ["error", "multiline"], "@stylistic/jsx-quotes": "error", @@ -82,7 +82,7 @@ export default tseslint.config( "@stylistic/new-parens": "error", "@stylistic/no-extra-semi": "error", "@stylistic/no-floating-decimal": "error", - "@stylistic/no-multi-spaces": "error", + "@stylistic/no-multi-spaces": ["error", { exceptions: { Property: false } }], "@stylistic/no-tabs": "error", "@stylistic/no-trailing-spaces": "error", "@stylistic/no-whitespace-before-property": "error", diff --git a/packages/discord-types/eslint.config.mjs b/packages/discord-types/eslint.config.mjs index 8f48e0872..8e29b3c25 100644 --- a/packages/discord-types/eslint.config.mjs +++ b/packages/discord-types/eslint.config.mjs @@ -57,15 +57,15 @@ export default tseslint.config( "@stylistic/new-parens": "error", "@stylistic/no-extra-semi": "error", "@stylistic/no-floating-decimal": "error", - "@stylistic/no-multi-spaces": "error", + "@stylistic/no-multi-spaces": ["error", { exceptions: { Property: false } }], "@stylistic/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }], "@stylistic/no-trailing-spaces": "error", "@stylistic/no-whitespace-before-property": "error", "@stylistic/object-curly-newline": "error", "@stylistic/object-curly-spacing": ["error", "always"], - "@stylistic/rest-spread-spacing": "error", "@stylistic/quote-props": ["error", "as-needed"], "@stylistic/quotes": ["error", "double", { avoidEscape: true }], + "@stylistic/rest-spread-spacing": "error", "@stylistic/semi": "error", "@stylistic/semi-spacing": "error", "@stylistic/semi-style": "error", @@ -166,13 +166,13 @@ export default tseslint.config( ignores: ["src/**"], rules: { "@typescript-eslint/no-unnecessary-type-parameters": "error", - "unicorn/prefer-node-protocol": "error", "simple-import-sort/imports": ["error", { groups: [ ["^((node:)?(assert(/strict)?|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|diagnostics_channel|dns(/promises)?|domain|events|fs(/promises)?|http|http2|https|module|net|os|path(/(posix|win32))?|perf_hooks|process|punycode|querystring|readline(/promises)?|repl|stream(/(consumers|promises|web))?|string_decoder|timers(/promises)?|tls|trace_events|tty|url|util(/types)?|v8|vm|wasi|worker_threads|zlib)|node:test(/reporters)?)$"], ["^[^.]"] ] }], + "unicorn/prefer-node-protocol": "error", } }, { diff --git a/src/globals.d.ts b/src/globals.d.ts index 9d4994e02..39e3690f5 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -84,13 +84,36 @@ declare global { ? Extract : ToArray; } + // https://github.com/microsoft/TypeScript/issues/26255 // https://github.com/microsoft/TypeScript/issues/29841 interface Array { + includes(searchElement: unknown, fromIndex?: number): boolean; + indexOf(searchElement: unknown, fromIndex?: number): number; + lastIndexOf(searchElement: unknown, fromIndex?: number): number; map(callbackfn: (value: T, index: TupleKeys, array: this) => U, thisArg?: any): MappedTuple; } interface ReadonlyArray { + includes(searchElement: unknown, fromIndex?: number): boolean; + indexOf(searchElement: unknown, fromIndex?: number): number; + lastIndexOf(searchElement: unknown, fromIndex?: number): number; map(callbackfn: (value: T, index: TupleKeys, array: this) => U, thisArg?: any): MappedTuple; } + interface Map { + delete(key: unknown): boolean; + get(key: unknown): V | undefined; + has(key: unknown): boolean; + } + interface ReadonlyMap { + get(key: unknown): V | undefined; + has(key: unknown): boolean; + } + interface Set { + delete(value: unknown): boolean; + has(value: unknown): boolean; + } + interface ReadonlySet { + has(value: unknown): boolean; + } /* eslint-enable @typescript-eslint/method-signature-style */ } diff --git a/src/plugins/memberCount/OnlineMemberCountStore.ts b/src/plugins/memberCount/OnlineMemberCountStore.ts index 76b28fbc4..3315eac56 100644 --- a/src/plugins/memberCount/OnlineMemberCountStore.ts +++ b/src/plugins/memberCount/OnlineMemberCountStore.ts @@ -17,7 +17,7 @@ export const OnlineMemberCountStore = proxyLazy(() => { class OnlineMemberCountStore extends Flux.Store { getCount(guildId?: string) { - return onlineMemberMap.get(guildId!); + return onlineMemberMap.get(guildId); } async _ensureCount(guildId: string) {