Bump dev (w/ eslint 8) (#4070)

* Bump dev (w/ eslint 8)

* Additional linting

* Additional

* More lint fixes

* Last batch

* Additional

* Cleanups
This commit is contained in:
Jaco
2021-10-17 14:49:26 +03:00
committed by GitHub
parent 806fda67e9
commit 5eb3534d8e
46 changed files with 328 additions and 307 deletions
+3 -3
View File
@@ -225,7 +225,7 @@ export class RpcCore {
observer.next(value);
observer.complete();
})
.catch((error): void => {
.catch((error: Error): void => {
logErrorMessage(method, def, error);
observer.error(error);
@@ -255,7 +255,7 @@ export class RpcCore {
this.provider
.subscribe(subType, subName, paramsJson, update)
.then(resolve)
.catch((error): void => {
.catch((error: Error): void => {
errorHandler(error);
reject(error);
});
@@ -283,7 +283,7 @@ export class RpcCore {
try {
const params = this._formatInputs(registry, null, def, values);
const paramsJson = params.map((param): AnyJson => param.toJSON());
const paramsJson = params.map((param) => param.toJSON());
const update = (error?: Error | null, result?: T): void => {
if (error) {
+4 -3
View File
@@ -1,6 +1,8 @@
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
import { MockProvider } from '@polkadot/rpc-provider/mock';
import { TypeRegistry } from '@polkadot/types/create';
import { isFunction } from '@polkadot/util';
@@ -12,7 +14,7 @@ describe('Api', (): void => {
it('requires a provider with a send method', (): void => {
expect(
() => new RpcCore('234', registry, {} as any)
() => new RpcCore('234', registry, {} as unknown as ProviderInterface)
).toThrow(/Expected Provider/);
});
@@ -28,8 +30,7 @@ describe('Api', (): void => {
}
});
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(isFunction((rpc as any).testing.foo)).toBe(true);
expect(isFunction((rpc as unknown as Record<string, Record<string, boolean>>).testing.foo)).toBe(true);
expect(rpc.sections.includes('testing')).toBe(true);
expect(rpc.mapping.get('testing_foo')).toEqual({
description: 'foo',
+6 -5
View File
@@ -1,6 +1,7 @@
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
import type { DefinitionRpc } from '@polkadot/types/types';
import { TypeRegistry } from '@polkadot/types/create';
@@ -11,7 +12,7 @@ describe('methodSend', (): void => {
const registry = new TypeRegistry();
let rpc: RpcCore;
let methods: Record<string, DefinitionRpc>;
let provider: any;
let provider: ProviderInterface;
beforeEach((): void => {
methods = {
@@ -30,10 +31,10 @@ describe('methodSend', (): void => {
};
provider = {
send: jest.fn((method, params: any[]): Promise<any> => {
return Promise.resolve(params[0]);
})
};
send: jest.fn((method: string, params: unknown[]): Promise<unknown> =>
Promise.resolve(params[0])
)
} as unknown as ProviderInterface;
rpc = new RpcCore('987', registry, provider);
});
+5 -4
View File
@@ -10,18 +10,19 @@ import { memoize } from '@polkadot/util';
import { drr } from './drr';
type ObsFn <T> = (...params: any[]) => Observable<T>;
type ObsFn <T> = (...params: unknown[]) => Observable<T>;
// Wraps a derive, doing 2 things to optimize calls -
// 1. creates a memo of the inner fn -> Observable, removing when unsubscribed
// 2. wraps the observable in a drr() (which includes an unsub delay)
/** @internal */
export function memo <T> (instanceId: string, inner: ObsFn<T>): Memoized<ObsFn<T>> {
// eslint-disable-next-line @typescript-eslint/ban-types
export function memo <T> (instanceId: string, inner: Function): Memoized<ObsFn<T>> {
const options = { getInstanceId: () => instanceId };
const cached = memoize(
(...params: any[]): Observable<T> =>
(...params: unknown[]): Observable<T> =>
new Observable((observer: Observer<T>): TeardownLogic => {
const subscription = inner(...params).subscribe(observer);
const subscription = (inner as ObsFn<T>)(...params).subscribe(observer);
return (): void => {
cached.unmemoize(...params);