diff --git a/.eslintrc b/.eslintrc index 8555963a..33e27c40 100644 --- a/.eslintrc +++ b/.eslintrc @@ -18,9 +18,8 @@ "@typescript-eslint/no-unsafe-assignment": "off", "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/ban-types": "off", + "no-nonoctal-decimal-escape": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/naming-convention": "off", - "no-nonoctal-decimal-escape": "off" + "@typescript-eslint/naming-convention": "off" } } diff --git a/shlink-web-client.d.ts b/shlink-web-client.d.ts index 4896a890..58d3c5df 100644 --- a/shlink-web-client.d.ts +++ b/shlink-web-client.d.ts @@ -2,7 +2,7 @@ declare module 'event-source-polyfill' { declare class EventSourcePolyfill { public onmessage?: ({ data }: { data: string }) => void; public onerror?: ({ status }: { status: number }) => void; - public close: Function; + public close: () => void; public constructor(hubUrl: URL, options?: any); } } diff --git a/src/container/index.ts b/src/container/index.ts index 58871f19..3cf33996 100644 --- a/src/container/index.ts +++ b/src/container/index.ts @@ -20,8 +20,8 @@ type LazyActionMap = Record; const bottle = new Bottle(); const { container } = bottle; -const lazyService = (container: IContainer, serviceName: string) => - (...args: any[]) => (container[serviceName] as T)(...args); +const lazyService = (container: IContainer, serviceName: string) => + (...args: any[]) => (container[serviceName] as T)(...args) as K; const mapActionService = (map: LazyActionMap, actionName: string): LazyActionMap => ({ ...map, // Wrap actual action service in a function so that it is lazily created the first time it is called diff --git a/src/mercure/helpers/boundToMercureHub.tsx b/src/mercure/helpers/boundToMercureHub.tsx index 5b5d5680..82ee96b7 100644 --- a/src/mercure/helpers/boundToMercureHub.tsx +++ b/src/mercure/helpers/boundToMercureHub.tsx @@ -6,7 +6,7 @@ import { bindToMercureTopic } from './index'; export interface MercureBoundProps { createNewVisits: (createdVisits: CreateVisit[]) => void; - loadMercureInfo: Function; + loadMercureInfo: () => void; mercureInfo: MercureInfo; } diff --git a/src/mercure/helpers/index.ts b/src/mercure/helpers/index.ts index bbd8a8d8..0368c8ee 100644 --- a/src/mercure/helpers/index.ts +++ b/src/mercure/helpers/index.ts @@ -1,7 +1,7 @@ import { EventSourcePolyfill as EventSource } from 'event-source-polyfill'; import { MercureInfo } from '../reducers/mercureInfo'; -export const bindToMercureTopic = (mercureInfo: MercureInfo, topics: string[], onMessage: (message: T) => void, onTokenExpired: Function) => { // eslint-disable-line max-len +export const bindToMercureTopic = (mercureInfo: MercureInfo, topics: string[], onMessage: (message: T) => void, onTokenExpired: () => void) => { // eslint-disable-line max-len const { mercureHubUrl, token, loading, error } = mercureInfo; if (loading || error || !mercureHubUrl) { diff --git a/src/servers/services/ServersExporter.ts b/src/servers/services/ServersExporter.ts index fb610276..114275ae 100644 --- a/src/servers/services/ServersExporter.ts +++ b/src/servers/services/ServersExporter.ts @@ -35,7 +35,7 @@ export default class ServersExporter { ) {} public readonly exportServers = async () => { - const servers = values(this.storage.get('servers') || {}).map(dissoc('id')); + const servers = values(this.storage.get('servers') ?? {}).map(dissoc('id')); try { const csv = this.csvjson.toCSV(servers, { diff --git a/src/utils/services/ColorGenerator.ts b/src/utils/services/ColorGenerator.ts index 7a9c8abd..46e988df 100644 --- a/src/utils/services/ColorGenerator.ts +++ b/src/utils/services/ColorGenerator.ts @@ -11,7 +11,7 @@ export default class ColorGenerator { private readonly colors: Record; public constructor(private readonly storage: LocalStorage) { - this.colors = this.storage.get>('colors') || {}; + this.colors = this.storage.get>('colors') ?? {}; } public readonly getColorForKey = (key: string) => { diff --git a/src/utils/services/LocalStorage.ts b/src/utils/services/LocalStorage.ts index 20bbb491..914a5a2c 100644 --- a/src/utils/services/LocalStorage.ts +++ b/src/utils/services/LocalStorage.ts @@ -4,10 +4,10 @@ const buildPath = (path: string) => `${PREFIX}.${path}`; export default class LocalStorage { public constructor(private readonly localStorage: Storage) {} - public readonly get = (key: string): T => { + public readonly get = (key: string): T | undefined => { const item = this.localStorage.getItem(buildPath(key)); - return item ? JSON.parse(item) : undefined; + return item ? JSON.parse(item) as T : undefined; }; public readonly set = (key: string, value: any) => this.localStorage.setItem(buildPath(key), JSON.stringify(value)); diff --git a/test/servers/services/ServersImporter.test.ts b/test/servers/services/ServersImporter.test.ts index f6749ca6..60e5dfc4 100644 --- a/test/servers/services/ServersImporter.test.ts +++ b/test/servers/services/ServersImporter.test.ts @@ -10,7 +10,9 @@ describe('ServersImporter', () => { const readAsText = jest.fn(); const fileReaderMock = Mock.of({ readAsText, - addEventListener: (_eventName: string, listener: Function) => listener({ target: { result: '' } }), + addEventListener: (_eventName: string, listener: (e: ProgressEvent) => void) => listener( + Mock.of>({ target: { result: '' } }), + ), }); const importer = new ServersImporter(csvjsonMock, () => fileReaderMock);