From da27a6ac64f9c87c2bff17642bc4918252748808 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Thu, 8 Jul 2021 16:55:48 -0500 Subject: [PATCH] Add `array-type` TypeScript ESLint rule --- .eslintrc.js | 2 ++ ts/components/conversation/Linkify.tsx | 2 +- ts/context/NativeThemeListener.ts | 7 +++++-- ts/sql/Server.ts | 2 +- ts/test-electron/quill/mentions/completion_test.tsx | 5 ++++- ts/textsecure/Crypto.ts | 4 ++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a3f4c9398e46..b14d306b330c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -117,6 +117,8 @@ const rules = { const typescriptRules = { ...rules, + '@typescript-eslint/array-type': ['error', { default: 'generic' }], + // Overrides recommended by typescript-eslint // https://github.com/typescript-eslint/typescript-eslint/releases/tag/v4.0.0 '@typescript-eslint/no-redeclare': 'error', diff --git a/ts/components/conversation/Linkify.tsx b/ts/components/conversation/Linkify.tsx index fb8948f5c53d..49a6d775b165 100644 --- a/ts/components/conversation/Linkify.tsx +++ b/ts/components/conversation/Linkify.tsx @@ -66,7 +66,7 @@ export class Linkify extends React.Component { const chunkData: Array<{ chunk: string; - matchData: LinkifyIt.Match[]; + matchData: ReadonlyArray; }> = splitByEmoji(text).map(({ type, value: chunk }) => { if (type === 'text') { return { chunk, matchData: linkify.match(chunk) || [] }; diff --git a/ts/context/NativeThemeListener.ts b/ts/context/NativeThemeListener.ts index 57bcd869c8da..9cd3fe3d9111 100644 --- a/ts/context/NativeThemeListener.ts +++ b/ts/context/NativeThemeListener.ts @@ -10,8 +10,11 @@ export interface MinimalIPC { // eslint-disable-next-line @typescript-eslint/no-explicit-any sendSync(channel: string): any; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - on(channel: string, listener: (event: unknown, ...args: any[]) => void): this; + on( + channel: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + listener: (event: unknown, ...args: ReadonlyArray) => void + ): this; } export type SystemThemeHolder = { systemTheme: 'dark' | 'light' }; diff --git a/ts/sql/Server.ts b/ts/sql/Server.ts index d70b15332a5a..64fddfe6b88a 100644 --- a/ts/sql/Server.ts +++ b/ts/sql/Server.ts @@ -248,7 +248,7 @@ const dataInterface: ServerInterface = { }; export default dataInterface; -type DatabaseQueryCache = Map>; +type DatabaseQueryCache = Map>>; const statementCache = new WeakMap(); diff --git a/ts/test-electron/quill/mentions/completion_test.tsx b/ts/test-electron/quill/mentions/completion_test.tsx index e3df2460ea2d..ee63d0aca1c6 100644 --- a/ts/test-electron/quill/mentions/completion_test.tsx +++ b/ts/test-electron/quill/mentions/completion_test.tsx @@ -94,7 +94,10 @@ describe('MentionCompletion', () => { }); describe('onTextChange', () => { - let possiblyShowMemberResultsStub: sinon.SinonStub<[], ConversationType[]>; + let possiblyShowMemberResultsStub: sinon.SinonStub< + [], + Array + >; beforeEach(() => { possiblyShowMemberResultsStub = sinon.stub( diff --git a/ts/textsecure/Crypto.ts b/ts/textsecure/Crypto.ts index 80cdc5b9d1bc..a8d22f1757e0 100644 --- a/ts/textsecure/Crypto.ts +++ b/ts/textsecure/Crypto.ts @@ -81,7 +81,7 @@ declare global { | DhImportKeyParams | AesKeyAlgorithm, extractable: boolean, - keyUsages: string[] + keyUsages: Array ): Promise; importKey( @@ -107,7 +107,7 @@ declare global { | DhImportKeyParams | AesKeyAlgorithm, extractable: boolean, - keyUsages: string[] + keyUsages: Array ): Promise; } }