Remove some eslint overrides (#5676)

* Remove some eslint overrides

* Use noop
This commit is contained in:
Jaco
2023-06-17 13:27:51 +03:00
committed by GitHub
parent 9913701e82
commit e89212b435
10 changed files with 21 additions and 39 deletions
@@ -36,12 +36,10 @@ async function main (): Promise<void> {
});
const pairs = createTestPairs();
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Promise.all([
await Promise.all([
checkBlueprint(api, pairs),
checkContract(api, pairs)
]);
}
// eslint-disable-next-line @typescript-eslint/unbound-method
main().catch(console.error);
+3 -4
View File
@@ -15,7 +15,7 @@ import { firstValueFrom, map, of, switchMap } from 'rxjs';
import { Metadata, TypeRegistry } from '@polkadot/types';
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
import { assertReturn, BN_ZERO, isUndefined, logger, objectSpread, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { assertReturn, BN_ZERO, isUndefined, logger, noop, objectSpread, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { cryptoWaitReady } from '@polkadot/util-crypto';
import { Decorate } from './Decorate.js';
@@ -77,8 +77,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// 'connected' event, then the `on('connected')` won't fire anymore. To
// cater for this case, we call manually `this._onProviderConnect`.
if (this._rpcCore.provider.isConnected) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.#onProviderConnect();
this.#onProviderConnect().catch(noop);
}
}
@@ -378,7 +377,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// Only enable the health keepalive on WS, not needed on HTTP
this.#healthTimer = this.hasSubscriptions
? setInterval((): void => {
firstValueFrom(this._rpcCore.system.health.raw()).catch(() => undefined);
firstValueFrom(this._rpcCore.system.health.raw()).catch(noop);
}, KEEPALIVE_INTERVAL)
: null;
}
+1 -4
View File
@@ -276,7 +276,6 @@ async function tx (api: ApiPromise, pairs: TestKeyringMapSubstrate): Promise<voi
// it allows for query & then using the submittable
const second = api.tx.democracy.second(123);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
await second.signAndSend('123', (result) => console.log(result));
// it handles enum inputs correctly
@@ -305,8 +304,7 @@ async function main (): Promise<void> {
const api = await ApiPromise.create();
const pairs = createTestPairs();
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Promise.all([
await Promise.all([
calls(api),
consts(api),
derive(api),
@@ -322,5 +320,4 @@ async function main (): Promise<void> {
]);
}
// eslint-disable-next-line @typescript-eslint/unbound-method
main().catch(console.error);
+2 -4
View File
@@ -4,7 +4,7 @@
import type { ApiOptions, UnsubscribePromise } from '../types/index.js';
import type { CombinatorCallback, CombinatorFunction } from './Combinator.js';
import { objectSpread } from '@polkadot/util';
import { noop, objectSpread } from '@polkadot/util';
import { ApiBase } from '../base/index.js';
import { Combinator } from './Combinator.js';
@@ -156,9 +156,7 @@ export class ApiPromise extends ApiBase<'promise'> {
// Swallow any rejections on isReadyOrError
// (in Node 15.x this creates issues, when not being looked at)
instance.isReadyOrError.catch(() => {
// ignore
});
instance.isReadyOrError.catch(noop);
return instance.isReady;
}
+5 -5
View File
@@ -4,7 +4,7 @@
import type { Callback } from '@polkadot/types/types';
import type { UnsubscribePromise } from '../types/index.js';
import { isFunction } from '@polkadot/util';
import { isFunction, noop } from '@polkadot/util';
export type CombinatorCallback <T extends unknown[]> = Callback<T>;
@@ -60,8 +60,9 @@ export class Combinator<T extends unknown[] = unknown[]> {
}
try {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.#callback(this.#results as T);
Promise
.resolve(this.#callback(this.#results as T))
.catch(noop);
} catch {
// swallow, we don't want the handler to trip us up
}
@@ -74,8 +75,7 @@ export class Combinator<T extends unknown[] = unknown[]> {
this.#isActive = false;
// eslint-disable-next-line @typescript-eslint/no-misused-promises
this.#subscriptions.forEach(async (subscription): Promise<void> => {
this.#subscriptions.map(async (subscription): Promise<void> => {
try {
const unsubscribe = await subscription;
-1
View File
@@ -21,7 +21,6 @@ describe('ApiPromise', (): void => {
const registry = new TypeRegistry();
const keyring = createTestKeyring({ type: 'ed25519' });
const aliceEd = keyring.addPair(
// eslint-disable-next-line @typescript-eslint/unbound-method
createPair({ toSS58: keyring.encodeAddress, type: 'ed25519' }, {
publicKey: hexToU8a('0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee'),
secretKey: hexToU8a('0xabf8e5bdbe30c65656c0a3cbd181ff8a56294a69dfedd27982aace4a7690911588dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee')
-1
View File
@@ -108,7 +108,6 @@ export class RpcCore {
* @param {ProviderInterface} provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
*/
constructor (instanceId: string, registry: Registry, { isPedantic = true, provider, userRpc = {} }: Options) {
// eslint-disable-next-line @typescript-eslint/unbound-method
if (!provider || !isFunction(provider.send)) {
throw new Error('Expected Provider to API create');
}
+2 -4
View File
@@ -26,9 +26,9 @@ describe('replay', (): void => {
it('returns the observable value', async (): Promise<void> => {
await new Promise<boolean>((resolve) => {
rpc.system.chain().subscribe((value: any): void => {
rpc.system.chain().subscribe((value?: { toString: () => string }): void => {
if (value) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access, jest/no-conditional-expect
// eslint-disable-next-line jest/no-conditional-expect
expect(value.toString()).toEqual('mockChain'); // Defined in MockProvider
resolve(true);
}
@@ -56,7 +56,6 @@ describe('replay', (): void => {
});
it('unsubscribes as required', async (): Promise<void> => {
// eslint-disable-next-line @typescript-eslint/unbound-method
rpc.provider.unsubscribe = jest.fn();
await new Promise<boolean>((resolve) => {
@@ -65,7 +64,6 @@ describe('replay', (): void => {
// There's a promise inside .unsubscribe(), wait a bit (> 2s)
setTimeout((): void => {
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(rpc.provider.unsubscribe).toHaveBeenCalled();
resolve(true);
}, 3500);
@@ -6,7 +6,7 @@ import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, Pro
import { EventEmitter } from 'eventemitter3';
import { isError, isFunction, isObject, logger, objectSpread } from '@polkadot/util';
import { isError, isFunction, isObject, logger, noop, objectSpread } from '@polkadot/util';
import { RpcCoder } from '../coder/index.js';
import { healthChecker } from './Health.js';
@@ -193,11 +193,11 @@ export class ScProvider implements ProviderInterface {
Promise
.race([
this.send(unsubscribeMethod, [id]).catch(() => undefined),
this.send(unsubscribeMethod, [id]).catch(noop),
new Promise((resolve) => setTimeout(resolve, 500))
])
.then(killStaleSubscriptions)
.catch(() => undefined);
.catch(noop);
};
hc.start((health) => {
+4 -10
View File
@@ -6,7 +6,7 @@ import type { EndpointStats, JsonRpcResponse, ProviderInterface, ProviderInterfa
import { EventEmitter } from 'eventemitter3';
import { isChildClass, isNull, isUndefined, logger, objectSpread } from '@polkadot/util';
import { isChildClass, isNull, isUndefined, logger, noop, objectSpread } from '@polkadot/util';
import { xglobal } from '@polkadot/x-global';
import { WebSocket } from '@polkadot/x-ws';
@@ -138,9 +138,7 @@ export class WsProvider implements ProviderInterface {
this.#timeout = timeout || DEFAULT_TIMEOUT_MS;
if (autoConnectMs && autoConnectMs > 0) {
this.connectWithRetry().catch((): void => {
// does not throw
});
this.connectWithRetry().catch(noop);
}
this.#isReadyPromise = new Promise((resolve): void => {
@@ -244,9 +242,7 @@ export class WsProvider implements ProviderInterface {
await this.connect();
} catch {
setTimeout((): void => {
this.connectWithRetry().catch((): void => {
// does not throw
});
this.connectWithRetry().catch(noop);
}, this.#autoConnectMs);
}
}
@@ -469,9 +465,7 @@ export class WsProvider implements ProviderInterface {
if (this.#autoConnectMs > 0) {
setTimeout((): void => {
this.connectWithRetry().catch(() => {
// does not throw
});
this.connectWithRetry().catch(noop);
}, this.#autoConnectMs);
}
};