Add TSLint (#106)

* Add TSLint

* Update dependencies

* Update dependencies
This commit is contained in:
Jaco Greeff
2018-06-27 12:22:52 +02:00
committed by GitHub
parent 2541e3f30d
commit f5a9c207d0
22 changed files with 194 additions and 133 deletions
+4 -4
View File
@@ -35,9 +35,9 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/jsonrpc": "^0.20.3",
"@polkadot/primitives-json": "^0.20.3",
"@polkadot/util": "^0.24.9",
"@polkadot/util-keyring": "^0.24.9"
"@polkadot/jsonrpc": "^0.26.6",
"@polkadot/primitives": "^0.26.6",
"@polkadot/util": "^0.26.6",
"@polkadot/util-keyring": "^0.26.6"
}
}
+2 -2
View File
@@ -6,8 +6,8 @@ import { Params, Param$Types } from '@polkadot/params/types';
import { FormatterFunction } from './types';
import addressDecode from '@polkadot/util-keyring/address/decode';
import bytesEncode from '@polkadot/primitives-json/bytes/encode';
import hashEncode from '@polkadot/primitives-json/hash/encode';
import bytesEncode from '@polkadot/primitives/json/bytes/encode';
import hashEncode from '@polkadot/primitives/json/hash/encode';
import format from './format';
+3 -3
View File
@@ -6,9 +6,9 @@ import { Param$Types } from '@polkadot/params/types';
import { FormatterFunction } from './types';
import addressEncode from '@polkadot/util-keyring/address/encode';
import bnDecode from '@polkadot/primitives-json/bn/decode';
import bytesDecode from '@polkadot/primitives-json/bytes/decode';
import headerDecode from '@polkadot/primitives-json/header/decode';
import bnDecode from '@polkadot/primitives/json/bn/decode';
import bytesDecode from '@polkadot/primitives/json/bytes/decode';
import headerDecode from '@polkadot/primitives/json/header/decode';
import isNull from '@polkadot/util/is/null';
import isUndefined from '@polkadot/util/is/undefined';
+4 -4
View File
@@ -39,10 +39,10 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/storage": "^0.20.3",
"@polkadot/util": "^0.24.9",
"@polkadot/util-crypto": "^0.24.9",
"@polkadot/util-keyring": "^0.24.9",
"@polkadot/storage": "^0.26.6",
"@polkadot/util": "^0.26.6",
"@polkadot/util-crypto": "^0.26.6",
"@polkadot/util-keyring": "^0.26.6",
"@types/nock": "^9.1.3",
"eventemitter3": "^2.0.3",
"isomorphic-fetch": "^2.2.1",
+1 -1
View File
@@ -27,4 +27,4 @@ export default function httpProvider (endpoint: string): ProviderInterface {
unsubscribe: (method: string, id: number): Promise<boolean> =>
unsubscribe(self, method, id)
};
};
}
@@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// tslint:disable-next-line
if (typeof fetch === 'undefined') {
require('isomorphic-fetch');
}
+1 -1
View File
@@ -23,4 +23,4 @@ export default async function send ({ coder, endpoint }: HttpState, method: stri
const result = await response.json();
return coder.decodeResponse(result);
};
}
+1 -1
View File
@@ -7,4 +7,4 @@ import { HttpState } from './types';
export default async function subscribe (self: HttpState, method: string, params: Array<any>, cb: ProviderInterface$Callback): Promise<number> {
throw new Error('Subscriptions has not been implemented');
};
}
+4 -4
View File
@@ -8,10 +8,10 @@ import { Storages } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { KeyringPair } from '@polkadot/util-keyring/types';
import { ProviderInterface$Emitted } from '../types';
import { MockState, MockState$Storage, MockState$Subscriptions, MockState$Subscription$Callback } from './types';
import { MockState, MockState$Storage, MockState$Subscriptions } from './types';
import BN from 'bn.js';
import headerEncode from '@polkadot/primitives-json/header/encode';
import headerEncode from '@polkadot/primitives/json/header/encode';
import createKey from '@polkadot/storage/key';
import state from '@polkadot/storage';
import bnToU8a from '@polkadot/util/bn/toU8a';
@@ -50,7 +50,7 @@ function updateSubs (subscriptions: MockState$Subscriptions, method: string, val
.values(subscriptions[method].callbacks)
.forEach((cb) => {
try {
(cb as MockState$Subscription$Callback)(null, value);
cb(null, value);
} catch (error) {
console.error(`Error on '${method}' subscription`, error);
}
@@ -86,4 +86,4 @@ export default function mocks ({ emitter, storage, subscriptions }: MockState):
updateSubs(subscriptions, 'subscribe_newHead', headerEncode(newHead));
}, 5000);
};
}
+1 -1
View File
@@ -9,7 +9,7 @@ import interfaces from '@polkadot/jsonrpc';
import u8aToHex from '@polkadot/util/u8a/toHex';
import logger from '@polkadot/util/logger';
const l =logger('api-mock');
const l = logger('api-mock');
const SUBSCRIPTIONS: string[] = Array.prototype.concat.apply(
[], Object.values(interfaces).map((area) =>
+1 -1
View File
@@ -15,7 +15,7 @@ import unsubscribe from './unsubscribe';
type WSProviderInterface = ProviderInterface & {
connect (): void
}
};
export default function wsProvider (endpoint: string, autoConnect: boolean = true): WSProviderInterface {
const self = state(endpoint, autoConnect);
+1 -1
View File
@@ -7,4 +7,4 @@ import { WsState } from './types';
export default function on (self: WsState, type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void {
self.emitter.on(type, sub);
};
}
+1 -1
View File
@@ -19,4 +19,4 @@ export default function onClose (self: WsState): () => void {
}, 1000);
}
};
};
}
+1 -1
View File
@@ -31,4 +31,4 @@ export default function onOpen (self: WsState): () => boolean {
return true;
};
};
}
+1
View File
@@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// tslint:disable-next-line
if (typeof WebSocket === 'undefined') {
// @ts-ignore
global.WebSocket = require('websocket').w3cwebsocket;
+1 -1
View File
@@ -27,4 +27,4 @@ export default function state (endpoint: string, autoConnect: boolean): WsState
subscriptions: {},
websocket: null
};
};
}
+1
View File
@@ -18,6 +18,7 @@ describe.skip('e2e', () => {
it('subscribes to client_newHead', (done) => {
let count = 0;
// tslint:disable-next-line
api.chain
.newHead((error: Error | null, data: any) => {
console.log('newHead: result =', [error, data]);
+17 -2
View File
@@ -8,7 +8,22 @@ const TEST_WS_URL = 'ws://localhost:9955';
let server: Server;
function createError ({ id, error: { code, message } }: { id: number, error: { code: number, message: string } }) {
type ErrorDef = {
id: number,
error: {
code: number,
message: string
}
};
type ReplyDef = {
id: number,
reply: {
result: any
}
};
function createError ({ id, error: { code, message } }: ErrorDef) {
return {
id,
jsonrpc: '2.0',
@@ -19,7 +34,7 @@ function createError ({ id, error: { code, message } }: { id: number, error: { c
};
}
function createReply ({ id, reply: { result } }: { id: number, reply: { result: any }}) {
function createReply ({ id, reply: { result } }: ReplyDef) {
return {
id,
jsonrpc: '2.0',
+3 -3
View File
@@ -37,8 +37,8 @@
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/api-format": "^0.14.8",
"@polkadot/api-provider": "^0.14.8",
"@polkadot/jsonrpc": "^0.20.3",
"@polkadot/params": "^0.20.3",
"@polkadot/util": "^0.24.9"
"@polkadot/jsonrpc": "^0.26.6",
"@polkadot/params": "^0.26.6",
"@polkadot/util": "^0.26.6"
}
}