mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 14:57:22 +03:00
Enabled @typescript-eslint/no-unsafe-return eslint rule again
This commit is contained in:
parent
ad0a889548
commit
ce0fc1094e
9 changed files with 14 additions and 13 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
2
shlink-web-client.d.ts
vendored
2
shlink-web-client.d.ts
vendored
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ type LazyActionMap = Record<string, Function>;
|
|||
const bottle = new Bottle();
|
||||
const { container } = bottle;
|
||||
|
||||
const lazyService = <T extends Function>(container: IContainer, serviceName: string) =>
|
||||
(...args: any[]) => (container[serviceName] as T)(...args);
|
||||
const lazyService = <T extends Function, K>(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
|
||||
|
|
|
@ -6,7 +6,7 @@ import { bindToMercureTopic } from './index';
|
|||
|
||||
export interface MercureBoundProps {
|
||||
createNewVisits: (createdVisits: CreateVisit[]) => void;
|
||||
loadMercureInfo: Function;
|
||||
loadMercureInfo: () => void;
|
||||
mercureInfo: MercureInfo;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { EventSourcePolyfill as EventSource } from 'event-source-polyfill';
|
||||
import { MercureInfo } from '../reducers/mercureInfo';
|
||||
|
||||
export const bindToMercureTopic = <T>(mercureInfo: MercureInfo, topics: string[], onMessage: (message: T) => void, onTokenExpired: Function) => { // eslint-disable-line max-len
|
||||
export const bindToMercureTopic = <T>(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) {
|
||||
|
|
|
@ -35,7 +35,7 @@ export default class ServersExporter {
|
|||
) {}
|
||||
|
||||
public readonly exportServers = async () => {
|
||||
const servers = values(this.storage.get<ServersMap>('servers') || {}).map(dissoc('id'));
|
||||
const servers = values(this.storage.get<ServersMap>('servers') ?? {}).map(dissoc('id'));
|
||||
|
||||
try {
|
||||
const csv = this.csvjson.toCSV(servers, {
|
||||
|
|
|
@ -11,7 +11,7 @@ export default class ColorGenerator {
|
|||
private readonly colors: Record<string, string>;
|
||||
|
||||
public constructor(private readonly storage: LocalStorage) {
|
||||
this.colors = this.storage.get<Record<string, string>>('colors') || {};
|
||||
this.colors = this.storage.get<Record<string, string>>('colors') ?? {};
|
||||
}
|
||||
|
||||
public readonly getColorForKey = (key: string) => {
|
||||
|
|
|
@ -4,10 +4,10 @@ const buildPath = (path: string) => `${PREFIX}.${path}`;
|
|||
export default class LocalStorage {
|
||||
public constructor(private readonly localStorage: Storage) {}
|
||||
|
||||
public readonly get = <T>(key: string): T => {
|
||||
public readonly get = <T>(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));
|
||||
|
|
|
@ -10,7 +10,9 @@ describe('ServersImporter', () => {
|
|||
const readAsText = jest.fn();
|
||||
const fileReaderMock = Mock.of<FileReader>({
|
||||
readAsText,
|
||||
addEventListener: (_eventName: string, listener: Function) => listener({ target: { result: '' } }),
|
||||
addEventListener: (_eventName: string, listener: (e: ProgressEvent<FileReader>) => void) => listener(
|
||||
Mock.of<ProgressEvent<FileReader>>({ target: { result: '' } }),
|
||||
),
|
||||
});
|
||||
const importer = new ServersImporter(csvjsonMock, () => fileReaderMock);
|
||||
|
||||
|
|
Loading…
Reference in a new issue