mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 14:57:22 +03:00
Enabled @typescript-eslint/no-unsafe-call eslint rule again
This commit is contained in:
parent
86544f4b24
commit
1fe76500e8
7 changed files with 18 additions and 13 deletions
|
@ -16,9 +16,8 @@
|
|||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
|
||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||
"@typescript-eslint/no-unsafe-call": "off",
|
||||
|
||||
"@typescript-eslint/no-unsafe-return": "off",
|
||||
"@typescript-eslint/naming-convention": "off",
|
||||
"@typescript-eslint/ban-types": "off",
|
||||
|
|
7
shlink-web-client.d.ts
vendored
7
shlink-web-client.d.ts
vendored
|
@ -1,5 +1,10 @@
|
|||
declare module 'event-source-polyfill' {
|
||||
export const EventSourcePolyfill: any;
|
||||
declare class EventSourcePolyfill {
|
||||
public onmessage?: ({ data }: { data: string }) => void;
|
||||
public onerror?: ({ status }: { status: number }) => void;
|
||||
public close: Function;
|
||||
public constructor(hubUrl: URL, options?: any);
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'csvjson' {
|
||||
|
|
|
@ -20,7 +20,8 @@ type LazyActionMap = Record<string, Function>;
|
|||
const bottle = new Bottle();
|
||||
const { container } = bottle;
|
||||
|
||||
const lazyService = (container: IContainer, serviceName: string) => (...args: any[]) => container[serviceName](...args);
|
||||
const lazyService = <T extends Function>(container: IContainer, serviceName: string) =>
|
||||
(...args: any[]) => (container[serviceName] as T)(...args);
|
||||
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
|
||||
|
|
|
@ -11,7 +11,7 @@ export const bindToMercureTopic = <T>(mercureInfo: MercureInfo, topics: string[]
|
|||
const onEventSourceMessage = ({ data }: { data: string }) => onMessage(JSON.parse(data) as T);
|
||||
const onEventSourceError = ({ status }: { status: number }) => status === 401 && onTokenExpired();
|
||||
|
||||
const subscriptions: EventSource[] = topics.map((topic) => {
|
||||
const subscriptions = topics.map((topic) => {
|
||||
const hubUrl = new URL(mercureHubUrl);
|
||||
|
||||
hubUrl.searchParams.append('topic', topic);
|
||||
|
|
|
@ -34,7 +34,7 @@ export const useToggle = (initialValue = false): ToggleResult => {
|
|||
|
||||
export const useSwipeable = (showSidebar: () => void, hideSidebar: () => void) => {
|
||||
const swipeMenuIfNoModalExists = (callback: () => void) => (e: any) => {
|
||||
const swippedOnVisitsTable = (e.event.composedPath() as HTMLElement[]).some( // eslint-disable-lin @typescript-eslint/no-unsafe-call
|
||||
const swippedOnVisitsTable = (e.event.composedPath() as HTMLElement[]).some( // eslint-disable-line @typescript-eslint/no-unsafe-call
|
||||
({ classList }) => classList?.contains('visits-table'),
|
||||
);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { EventSourcePolyfill as EventSource } from 'event-source-polyfill';
|
||||
import { EventSourcePolyfill } from 'event-source-polyfill';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { identity } from 'ramda';
|
||||
import { bindToMercureTopic } from '../../../src/mercure/helpers';
|
||||
|
@ -22,7 +22,7 @@ describe('helpers', () => {
|
|||
])('does not bind an EventSource when loading, error or no hub URL', (mercureInfo) => {
|
||||
bindToMercureTopic(mercureInfo, [ '' ], identity, identity);
|
||||
|
||||
expect(EventSource).not.toHaveBeenCalled();
|
||||
expect(EventSourcePolyfill).not.toHaveBeenCalled();
|
||||
expect(onMessage).not.toHaveBeenCalled();
|
||||
expect(onTokenExpired).not.toHaveBeenCalled();
|
||||
});
|
||||
|
@ -42,16 +42,16 @@ describe('helpers', () => {
|
|||
token,
|
||||
}, [ topic ], onMessage, onTokenExpired);
|
||||
|
||||
expect(EventSource).toHaveBeenCalledWith(hubUrl, {
|
||||
expect(EventSourcePolyfill).toHaveBeenCalledWith(hubUrl, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
const [ es ] = EventSource.mock.instances;
|
||||
const [ es ] = (EventSourcePolyfill as any).mock.instances as EventSourcePolyfill[];
|
||||
|
||||
es.onmessage({ data: '{"foo": "bar"}' });
|
||||
es.onerror({ status: 401 });
|
||||
es.onmessage?.({ data: '{"foo": "bar"}' });
|
||||
es.onerror?.({ status: 401 });
|
||||
expect(onMessage).toHaveBeenCalledWith({ foo: 'bar' });
|
||||
expect(onTokenExpired).toHaveBeenCalled();
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ describe('<ShortUrlsRowMenu />', () => {
|
|||
const wrapper = createWrapper();
|
||||
|
||||
expect(wrapper.find(modalComponent).prop('isOpen')).toEqual(false);
|
||||
wrapper.find(modalComponent).prop('toggle')();
|
||||
(wrapper.find(modalComponent).prop('toggle') as Function)();
|
||||
expect(wrapper.find(modalComponent).prop('isOpen')).toEqual(true);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue