eslint rules (#1099)

* Off to the races - 3760 problems (1794 errors, 1966 warnings)

* Convert Array<T> -> T[] (not all correct, eg. extends)

* () => { -> (): void  => {

* get is/as -> public get is/as

* public for getters, constructors & base Codec

* Some cleanups from previous overzealous search & replace

* Under 2k, 1874 problems (649 errors, 1225 warnings)

* ^^^ check that commit for details ;)

* Minor.

* rm config header

* Minor cleanups

* Default to tslint, eslint as option

* Trigger

* Update jsonrpc

* 1494 problems (433 errors, 1061 warnings)

* 1103 problems (135 errors, 968 warnings)

* 899 problems (9 errors, 890 warnings)

* 483 problems (9 errors, 474 warnings) (ignore any... for now)

* 366 problems (9 errors, 357 warnings)

* 336 problems (9 errors, 327 warnings)

* 148 problems (9 errors, 139 warnings)

* 31 problems (8 errors, 23 warnings)

* 0, 0
This commit is contained in:
Jaco Greeff
2019-07-14 12:15:14 +02:00
committed by GitHub
parent f770fb973f
commit 71c5920b1f
354 changed files with 3817 additions and 3632 deletions
+3 -3
View File
@@ -5,15 +5,15 @@
import BN from 'bn.js';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterface$Rx } from '@polkadot/api/types';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { drr } from '../util/drr';
import { info } from './info';
export function eraLength (api: ApiInterface$Rx) {
export function eraLength (api: ApiInterfaceRx): () => Observable<BN> {
return (): Observable<BN> =>
info(api)().pipe(
map(({ eraLength }) => eraLength),
map(({ eraLength }): BN => eraLength),
drr()
);
}
@@ -5,15 +5,15 @@
import BN from 'bn.js';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterface$Rx } from '@polkadot/api/types';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { drr } from '../util/drr';
import { info } from './info';
export function eraProgress (api: ApiInterface$Rx) {
export function eraProgress (api: ApiInterfaceRx): () => Observable<BN> {
return (): Observable<BN> =>
info(api)().pipe(
map(({ eraProgress }) => eraProgress),
map(({ eraProgress }): BN => eraProgress),
drr()
);
}
+34 -30
View File
@@ -7,19 +7,19 @@ import { DerivedSessionInfo } from '../types';
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterface$Rx } from '@polkadot/api/types';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { BlockNumber, Option } from '@polkadot/types';
import { drr } from '../util/drr';
import { bestNumber } from '../chain';
type Result_0_94 = [BN, [BN, Option<BlockNumber>, BN, BN, BN]];
type Result0to94 = [BN, [BN, Option<BlockNumber>, BN, BN, BN]];
type Result = [BN, [BN, BN]];
const ZERO = new BN(0);
// internal helper to just split the logic - take all inputs, do the calculations and combine
function createDerived_0_94 ([bestNumber, [currentIndex, _lastLengthChange, sessionLength, lastEraLengthChange, sessionsPerEra]]: Result_0_94): DerivedSessionInfo {
function createDerived0to94 ([bestNumber, [currentIndex, _lastLengthChange, sessionLength, lastEraLengthChange, sessionsPerEra]]: Result0to94): DerivedSessionInfo {
const eraLength = sessionLength.mul(sessionsPerEra);
const lastLengthChange = _lastLengthChange
? _lastLengthChange.unwrapOr(ZERO)
@@ -45,7 +45,7 @@ function createDerived_0_94 ([bestNumber, [currentIndex, _lastLengthChange, sess
sessionLength,
sessionsPerEra,
sessionProgress
} as DerivedSessionInfo;
} as unknown as DerivedSessionInfo;
}
function createDerived ([sessionsPerEra, [currentIndex, currentEra]]: Result): DerivedSessionInfo {
@@ -61,43 +61,47 @@ function createDerived ([sessionsPerEra, [currentIndex, currentEra]]: Result): D
sessionLength: ZERO,
sessionsPerEra,
sessionProgress: ZERO
} as DerivedSessionInfo;
} as unknown as DerivedSessionInfo;
}
/**
* @description Retrieves all the session and era info and calculates specific values on it as the length of the session and eras
*/
export function info (api: ApiInterface$Rx) {
export function info (api: ApiInterfaceRx): () => Observable<DerivedSessionInfo> {
return (): Observable<DerivedSessionInfo> => {
// With substrate `spec_version 94`, the era and session has been explicitly exposed as `parameter_types`.
// pre-94 we had more info and needed to calculate (handle old/Alex first)
// https://github.com/paritytech/substrate/commit/dbf322620948935d2bbae214504e6c668c3073ed#diff-c29f42d6b931fa93ba038dbbbfec3055
return api.query.session.lastLengthChange
? (combineLatest([
bestNumber(api)(),
api.queryMulti([
api.query.session.currentIndex,
api.query.session.lastLengthChange,
api.query.session.sessionLength,
api.query.staking.lastEraLengthChange,
api.query.staking.sessionsPerEra
])
]) as any as Observable<Result_0_94>).pipe(
map(createDerived_0_94),
? (
combineLatest([
bestNumber(api)(),
api.queryMulti([
api.query.session.currentIndex,
api.query.session.lastLengthChange,
api.query.session.sessionLength,
api.query.staking.lastEraLengthChange,
api.query.staking.sessionsPerEra
])
]) as any as Observable<Result0to94>
).pipe(
map(createDerived0to94),
drr()
)
: (combineLatest([
// sessionsPerEra:
// substrate spec_version >= 94 : get from parameter_types exposed as api.consts
// https://github.com/paritytech/substrate/pull/2802/files#diff-5e5e1c3aec9ddfde0a9054d062ab3db9R156
of(api.consts.staking.sessionsPerEra),
api.queryMulti([
api.query.session.currentIndex,
api.query.staking.currentEra
])
]) as any as Observable<Result>).pipe(
map(createDerived),
drr()
);
: (
combineLatest([
// sessionsPerEra:
// substrate spec_version >= 94 : get from parameter_types exposed as api.consts
// https://github.com/paritytech/substrate/pull/2802/files#diff-5e5e1c3aec9ddfde0a9054d062ab3db9R156
of(api.consts.staking.sessionsPerEra),
api.queryMulti([
api.query.session.currentIndex,
api.query.staking.currentEra
])
]) as unknown as Observable<Result>
).pipe(
map(createDerived),
drr()
);
};
}
@@ -5,15 +5,15 @@
import BN from 'bn.js';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterface$Rx } from '@polkadot/api/types';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { drr } from '../util/drr';
import { info } from './info';
export function sessionProgress (api: ApiInterface$Rx) {
export function sessionProgress (api: ApiInterfaceRx): () => Observable<BN> {
return (): Observable<BN> =>
info(api)().pipe(
map(({ sessionProgress }) => sessionProgress),
map(({ sessionProgress }): BN => sessionProgress),
drr()
);
}