Skip to content

Commit

Permalink
tslint.json: enable 'no-unused-variable' warning. (coinbase#223)
Browse files Browse the repository at this point in the history
Set up an ignore pattern to ignore variables starting with a single _.

https://palantir.github.io/tslint/rules/no-unused-variable/
  • Loading branch information
blair authored and fb55 committed Apr 16, 2018
1 parent 54e425f commit cdeca2a
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/core/HFTFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class HFTFilter extends Duplex {
/**
* If this stream has another stream piped into it, we just pass the data into the READABLE stream's filter
*/
_write(chunk: any, encoding: string, callback: (err: Error) => void) {
_write(chunk: any, _encoding: string, callback: (err: Error) => void) {
if (typeof chunk === 'object' && isStreamMessage(chunk)) {
this.filterMessage(chunk as StreamMessage);
return callback(null);
Expand Down
2 changes: 1 addition & 1 deletion src/core/LiveOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class LiveOrderbook extends Duplex implements Orderbook {

_read() { /* no-op */ }

_write(msg: any, encoding: string, callback: () => void): void {
_write(msg: any, _encoding: string, callback: () => void): void {
// Pass the msg on to downstream users
this.push(msg);
// Process the message for the orderbook state
Expand Down
2 changes: 1 addition & 1 deletion src/core/MessageQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class MessageQueue extends Duplex {
this.messages.clear();
}

_write(inputMessage: any, encoding: string, callback: (err: Error) => void): void {
_write(inputMessage: any, _encoding: string, callback: (err: Error) => void): void {
if (this.defaultMessageHandler(inputMessage)) {
setImmediate(() => {
this._read();
Expand Down
2 changes: 1 addition & 1 deletion src/core/RateLimiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class RateLimiter extends Transform {
this.limiter = new Limiter(limit, interval, false);
}

_transform(msg: StreamMessage, encoding: string, callback: (err?: Error, data?: any) => void): void {
_transform(msg: StreamMessage, _encoding: string, callback: (err?: Error, data?: any) => void): void {
this.limiter.removeTokens(1, () => {
msg.time = new Date();
this.push(msg);
Expand Down
2 changes: 1 addition & 1 deletion src/core/Trader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class Trader extends Writable {
}
}

_write(msg: any, encoding: string, callback: (err?: Error) => any): void {
_write(msg: any, _encoding: string, callback: (err?: Error) => any): void {
this.executeMessage(msg);
callback();
}
Expand Down
4 changes: 2 additions & 2 deletions src/exchanges/ExchangeFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export abstract class ExchangeFeed extends Readable {
this.close();
}

_read(size: number) {
_read(_size: number) {
// This is not an on-demand service. For that, I refer you to Netflix. Data gets pushed to the queue as it comes
// in from the websocket, so there's nothing to do here.
}
Expand Down Expand Up @@ -123,7 +123,7 @@ export abstract class ExchangeFeed extends Readable {

protected abstract onOpen(): void;

protected onClose(code: number, reason: string): void {
protected onClose(_code: number, _reason: string): void {
this.emit('websocket-closed');
this.socket = null;
}
Expand Down
12 changes: 6 additions & 6 deletions src/exchanges/bitfinex/BitfinexExchangeAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class BitfinexExchangeAPI implements PublicExchangeAPI, AuthenticatedExch
});
}

cancelAllOrders(gdaxProduct?: string): Promise<string[]> {
cancelAllOrders(_gdaxProduct?: string): Promise<string[]> {
return this.checkAuth().then((auth: ExchangeAuthConfig) => {
return BitfinexAuth.cancelAllOrders(auth).then((result: BitfinexResult) => {
if (this.logger) {
Expand All @@ -246,7 +246,7 @@ export class BitfinexExchangeAPI implements PublicExchangeAPI, AuthenticatedExch
});
}

loadAllOrders(gdaxProduct?: string): Promise<LiveOrder[]> {
loadAllOrders(_gdaxProduct?: string): Promise<LiveOrder[]> {
return this.checkAuth().then((auth: ExchangeAuthConfig) => {
return BitfinexAuth.activeOrders(auth).then((results: BitfinexSuccessfulOrderExecution[]) => {
if (this.logger) {
Expand Down Expand Up @@ -279,13 +279,13 @@ export class BitfinexExchangeAPI implements PublicExchangeAPI, AuthenticatedExch
});
}

loadCandles(options: CandleRequestOptions): Promise<Candle[]> {
loadCandles(_options: CandleRequestOptions): Promise<Candle[]> {
return Promise.reject(new GTTError('Not implemented'));
}

// -------------------------- Transfer methods -------------------------------------------------

requestCryptoAddress(cur: string): Promise<CryptoAddress> {
requestCryptoAddress(_cur: string): Promise<CryptoAddress> {
return Promise.reject(new GTTError('Not implemented'));
}

Expand Down Expand Up @@ -318,11 +318,11 @@ export class BitfinexExchangeAPI implements PublicExchangeAPI, AuthenticatedExch
});
}

requestWithdrawal(req: WithdrawalRequest): Promise<TransferResult> {
requestWithdrawal(_req: WithdrawalRequest): Promise<TransferResult> {
return Promise.reject(new GTTError('Not implemented'));
}

transfer(cur: string, amount: BigJS, from: string, to: string, options: any): Promise<TransferResult> {
transfer(_cur: string, _amount: BigJS, _from: string, _to: string, _options: any): Promise<TransferResult> {
return Promise.reject(new GTTError('Not implemented'));
}

Expand Down
4 changes: 2 additions & 2 deletions src/exchanges/bitmex/BitmexMarketFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class BitmexMarketFeed extends ExchangeFeed {
this.orderIdMap = newIdMap;

const mapLevelUpdates: (date: PriceData) => PriceLevelWithOrders =
({ id, price, size, side }) => PriceLevelFactory(price, size, Side(side));
({ price, size, side }) => PriceLevelFactory(price, size, Side(side));

const asks: PriceLevelWithOrders[] = snapshot.data
.filter( ({ side }) => side === 'Sell' )
Expand Down Expand Up @@ -194,7 +194,7 @@ export class BitmexMarketFeed extends ExchangeFeed {
});
}

private handleSubscriptionSuccess(successMsg: SubscriptionResponseMessage) {
private handleSubscriptionSuccess(_successMsg: SubscriptionResponseMessage) {
// TODO
}
}
2 changes: 1 addition & 1 deletion src/exchanges/bittrex/BittrexFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class BittrexFeed extends ExchangeFeed {
// no-op
}

protected onClose(code: number, reason: string): void {
protected onClose(_code: number, _reason: string): void {
this.emit('websocket-closed');
this.connection = null;
}
Expand Down
20 changes: 10 additions & 10 deletions src/exchanges/ccxt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,19 @@ export default class CCXTExchangeWrapper implements PublicExchangeAPI, Authentic

}

cancelOrder(id: string): Promise<string> {
cancelOrder(_id: string): Promise<string> {
return Promise.reject(new Error('Not implemented yet'));
}

cancelAllOrders(gdaxProduct?: string): Promise<string[]> {
cancelAllOrders(_gdaxProduct?: string): Promise<string[]> {
return Promise.reject(new Error('Not implemented yet'));
}

loadOrder(id: string): Promise<LiveOrder> {
loadOrder(_id: string): Promise<LiveOrder> {
return Promise.reject(new Error('Not implemented yet'));
}

loadAllOrders(gdaxProduct?: string): Promise<LiveOrder[]> {
loadAllOrders(_gdaxProduct?: string): Promise<LiveOrder[]> {
return Promise.reject(new Error('Not implemented yet'));
}

Expand Down Expand Up @@ -368,19 +368,19 @@ export default class CCXTExchangeWrapper implements PublicExchangeAPI, Authentic
}).catch((err: Error) => rejectWithError(`Error loading balances on ${this.instance.name} (CCXT)`, err));
}

requestCryptoAddress(cur: string): Promise<CryptoAddress> {
requestCryptoAddress(_cur: string): Promise<CryptoAddress> {
return Promise.reject(new Error('Not implemented yet'));
}

requestTransfer(request: TransferRequest): Promise<TransferResult> {
requestTransfer(_request: TransferRequest): Promise<TransferResult> {
return Promise.reject(new Error('Not implemented yet'));
}

requestWithdrawal(request: WithdrawalRequest): Promise<TransferResult> {
requestWithdrawal(_request: WithdrawalRequest): Promise<TransferResult> {
return Promise.reject(new Error('Not implemented yet'));
}

transfer(cur: string, amount: BigJS, from: string, to: string, options: any): Promise<TransferResult> {
transfer(_cur: string, _amount: BigJS, _from: string, _to: string, _options: any): Promise<TransferResult> {
return Promise.reject(new Error('Not implemented yet'));
}

Expand All @@ -391,10 +391,10 @@ export default class CCXTExchangeWrapper implements PublicExchangeAPI, Authentic
const sourceSymbol = await this.getSourceSymbol(symbol);
try {
const rawTrades = await this.instance.fetchTrades(sourceSymbol, since, limit, params);
return rawTrades.map(({info, id, timestamp, datetime, symbol: _symbol, order, type, side, price, amount}) => ({
return rawTrades.map(({id, timestamp, symbol: productId, side, price, amount}) => ({
type: 'trade' as 'trade',
time: new Date(timestamp),
productId: _symbol,
productId,
side,
tradeId: id,
price: price.toString(),
Expand Down
2 changes: 1 addition & 1 deletion src/exchanges/gdax/GDAXExchangeAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export class GDAXExchangeAPI implements PublicExchangeAPI, AuthenticatedExchange
};
}

handleResponse<T>(req: Promise<Response>, meta: any): Promise<T> {
handleResponse<T>(req: Promise<Response>, _meta: any): Promise<T> {
return req.then((res: Response) => {
if (res.status >= 200 && res.status < 300) {
return res.body;
Expand Down
2 changes: 1 addition & 1 deletion src/exchanges/gemini/GeminiMarketFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class GeminiMarketFeed extends ExchangeFeed {
return message;
}

private processAuction(event: GI.GeminiAuctionEvent, update: GI.GeminiUpdateMessage): StreamMessage {
private processAuction(_event: GI.GeminiAuctionEvent, _update: GI.GeminiUpdateMessage): StreamMessage {
// TODO: Are auctions unique to Gemini?
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/exchanges/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { extractResponse, HTTPError } from '../lib/errors';
* @param meta
* @returns {Promise<Response>}
*/
export function handleResponse<T>(req: Promise<Response>, meta: any): Promise<T> {
export function handleResponse<T>(req: Promise<Response>, _meta: any): Promise<T> {
return req.then<T>((res: Response) => {
if (res.status >= 200 && res.status < 300) {
return res.body as T;
Expand Down
2 changes: 1 addition & 1 deletion src/factories/geminiFactories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Logger } from '../utils/Logger';
import { getFeed } from '../exchanges/ExchangeFeed';

export function getSubscribedFeeds(options: any, symbol: string): Promise<GeminiMarketFeed> {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
const config: GI.GeminiMarketFeedConfig = {
wsUrl: (options.wsUrl || GEMINI_WS_FEED) + symbol,
auth: null,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/AbstractMessageTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export abstract class AbstractMessageTransform extends stream.Transform {
return super.read(size) as StreamMessage;
}

_transform(chunk: any, encoding: string, callback: (err: Error, chunk?: any) => void) {
_transform(chunk: any, _encoding: string, callback: (err: Error, chunk?: any) => void) {
if (typeof chunk === 'object' && isStreamMessage(chunk)) {
const msg = chunk as StreamMessage;
const transformed = this.transformMessage(msg);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/StaticCommandSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ export class StaticCommandSet extends Readable {
this.push(null);
}

_read(size: number): void { /* no-op */
_read(_size: number): void { /* no-op */
}
}
2 changes: 1 addition & 1 deletion src/lib/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This function never throws and does no work, it's meant to only
* provide a static compile time check.
*/
export function staticAssertNever(x: never): void {
export function staticAssertNever(_x: never): void {
// This block is deliberately empty as this is a static compile
// time check function.
}
2 changes: 1 addition & 1 deletion src/server/DataFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function dataFeedFactory(): Server {
if (server === undefined) {
server = new Server(serverOptions);
logger.log('info', `Websocket server listening on port ${server.options.port}`);
server.on('connection', (socket: WebSocket) => {
server.on('connection', (_socket: WebSocket) => {
logger.log('debug', 'Websocket connection made to ' + server.options.host);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export function ConsoleLoggerFactory(options?: winston.ConsoleTransportOptions):
}

export const NullLogger = {
log(level: string, message: string, meta?: any): void { /* no-op */
log(_level: string, _message: string, _meta?: any): void { /* no-op */
},
error(err: Error): void { /* no-op */
error(_err: Error): void { /* no-op */
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function eachParallelAndFinish<T, U>(arr: T[], iteratorFn: (arg: T) => Pr
* Applies iteratorFn to each element in arr until a 'true' result is returned. Rejected promises are swallowed. A false result is returned only
* if every iteratorFn(i) returns false or an Error
*/
export async function tryUntil<T, U>(arr: T[], iteratorFn: (arg: T) => Promise<U | boolean>, index: number = 0): Promise<U | boolean> {
export async function tryUntil<T, U>(arr: T[], iteratorFn: (arg: T) => Promise<U | boolean>): Promise<U | boolean> {
if (arr.length < 1) {
return Promise.resolve(false);
}
Expand Down
2 changes: 1 addition & 1 deletion test/FXService/CryptoProviderTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('CryptoProvider', () => {
nock('https://api.gdax.com:443')
.get('/products/BTC-XYZ/ticker')
.reply(404, { message: 'NotFound' });
return provider.fetchCurrentRate({ from: 'BTC', to: 'XYZ' }).then((result: FXObject) => {
return provider.fetchCurrentRate({ from: 'BTC', to: 'XYZ' }).then((_result: FXObject) => {
throw new Error('should reject this promise');
}).catch((err: Error) => {
assert.ok(err instanceof EFXRateUnavailable);
Expand Down
2 changes: 1 addition & 1 deletion test/FXService/FailoverProviderTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('FailoverProvider', () => {
nock('https://api.gdax.com:443')
.get('/products/BTC-XYZ/ticker')
.reply(404, { message: 'NotFound' });
return provider.fetchCurrentRate({ from: 'BTC', to: 'XYZ' }).then((result: FXObject) => {
return provider.fetchCurrentRate({ from: 'BTC', to: 'XYZ' }).then((_result: FXObject) => {
throw new Error('should reject this promise');
}).catch((err: Error) => {
assert.ok(err instanceof EFXRateUnavailable);
Expand Down
2 changes: 1 addition & 1 deletion test/FXService/OpenExchangeRateTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('OpenExchangeProvider', () => {

it('rejects for unsupported currencies', () => {
// Still cached
return provider.fetchCurrentRate({ from: 'USD', to: 'XYZ' }).then((result: FXObject) => {
return provider.fetchCurrentRate({ from: 'USD', to: 'XYZ' }).then((_result: FXObject) => {
throw new Error('should reject this promise');
}).catch((err: Error) => {
assert.ok(err instanceof EFXRateUnavailable);
Expand Down
5 changes: 5 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"member-access": false,
"no-console": false,
"no-trailing-whitespace": [true, "ignore-comments", "ignore-jsdoc"],
"no-unused-variable": [
true,
"check-parameters",
{"ignore-pattern": "^_"}
],
"object-literal-shorthand": false,
"object-literal-sort-keys": false,
"ordered-imports": false,
Expand Down

0 comments on commit cdeca2a

Please sign in to comment.