From 6c0ad602dafa6234c68905b0789ac39bf675f294 Mon Sep 17 00:00:00 2001 From: GloriousCode Date: Thu, 16 Aug 2018 17:32:25 +1000 Subject: [PATCH] Lint fixes --- web/package.json | 4 +- web/src/app/app.component.ts | 5 +- .../app/pages/settings/settings.component.ts | 48 +++++++++++-------- web/src/app/pages/wallet/wallet.component.ts | 25 ++++++---- .../websocket-response-handler.service.ts | 8 +++- .../services/websocket/websocket.service.ts | 2 +- web/src/app/shared/classes/config.ts | 11 +++-- web/src/app/shared/classes/websocket.ts | 16 +++---- .../shared/my-orders/my-orders.component.ts | 15 +++--- web/src/app/shared/orders/orders.component.ts | 15 +++--- .../theme-picker/theme-picker.component.ts | 1 - .../trade-history/trade-history.component.ts | 14 +++--- web/src/polyfills.ts | 6 +-- web/src/tsconfig.spec.json | 2 +- web/tsconfig.json | 3 +- web/tslint.json | 3 +- 16 files changed, 95 insertions(+), 83 deletions(-) diff --git a/web/package.json b/web/package.json index 57973963..8bc56015 100644 --- a/web/package.json +++ b/web/package.json @@ -32,8 +32,8 @@ "start": "node hooks/environments/set_profile.js && npm-run-all -p ng:serve electron:serve", "build": "node hooks/environments/set_profile.js && ng build && npm run electron:tsc", "build:prod": "node hooks/environments/set_profile.js && ng build --prod && npm run electron:tsc", - "lint": "tslint -c tslint.json src/**/*{.ts,.tsx} main.ts", - "lint:fix": "tslint --fix -c tslint.json src/**/*{.ts,.tsx} main.ts", + "lint": "tslint --project tslint.json src/**/*{.ts,.tsx} main.ts", + "lint:fix": "tslint --fix --project tslint.json src/**/*{.ts,.tsx} main.ts", "ng:serve": "ng serve -o", "electron:tsc": "tsc main.ts", "electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:tsc && electron . --serve", diff --git a/web/src/app/app.component.ts b/web/src/app/app.component.ts index 180ae60d..794eb5f5 100644 --- a/web/src/app/app.component.ts +++ b/web/src/app/app.component.ts @@ -17,7 +17,10 @@ export class AppComponent implements OnInit { private ws: WebsocketResponseHandlerService; public isConnected = false; - constructor(public electronService: ElectronService, sidebarService: SidebarService, private router: Router, private websocketHandler: WebsocketResponseHandlerService) { + constructor(public electronService: ElectronService, + sidebarService: SidebarService, + private router: Router, + private websocketHandler: WebsocketResponseHandlerService) { if (electronService.isElectron()) { console.log('Mode electron'); diff --git a/web/src/app/pages/settings/settings.component.ts b/web/src/app/pages/settings/settings.component.ts index e10ce2f4..8c307bd2 100644 --- a/web/src/app/pages/settings/settings.component.ts +++ b/web/src/app/pages/settings/settings.component.ts @@ -5,6 +5,28 @@ import { Config, CurrencyPairRedux, Wallet } from './../../shared/classes/config import { MatSnackBar, MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; import { WalletComponent } from '../wallet/wallet.component'; +@Component({ + selector: 'app-dialog-overview-example-dialog', + template: '

Enabled Currencies

' + + '{{currency.Name}}' + + '
', +}) +export class EnabledCurrenciesDialogueComponent { + + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any) { } + + onNoClick(): void { + this.dialogRef.close(); + } + + public close(): void { + this.dialogRef.close(); + + } +} + @Component({ selector: 'app-settings', templateUrl: './settings.component.html', @@ -18,10 +40,13 @@ export class SettingsComponent implements OnInit { private snackBar: MatSnackBar; private dialogue; - constructor(private websocketHandler: WebsocketResponseHandlerService, snackBar: MatSnackBar, public dialog: MatDialog) { + constructor(private websocketHandler: WebsocketResponseHandlerService, + snackBar: MatSnackBar, + public dialog: MatDialog) { this.ws = websocketHandler; this.snackBar = snackBar; } + ngOnInit() { this.ws.shared.subscribe(msg => { if (msg.event === WebSocketMessageType.GetConfig) { @@ -82,25 +107,6 @@ export class SettingsComponent implements OnInit { } } -@Component({ - selector: 'app-dialog-overview-example-dialog', - template: '

Enabled Currencies

{{currency.Name}}
', -}) -export class EnabledCurrenciesDialogueComponent { - - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any) { } - - onNoClick(): void { - this.dialogRef.close(); - } - - public close(): void { - this.dialogRef.close(); - - } - -} + diff --git a/web/src/app/pages/wallet/wallet.component.ts b/web/src/app/pages/wallet/wallet.component.ts index b0faec12..fe6b088b 100644 --- a/web/src/app/pages/wallet/wallet.component.ts +++ b/web/src/app/pages/wallet/wallet.component.ts @@ -28,18 +28,23 @@ export class WalletComponent implements OnInit { this.ws.shared.subscribe(msg => { if (msg.event === WebSocketMessageType.GetPortfolio) { this.wallet = msg.data; - console.log(msg.data); - this.attachIcon(this.wallet.coin_totals); - this.attachIcon(this.wallet.coins_offline); - this.attachIcon(this.wallet.coins_online); + console.log('wallet: ' + msg.data); + console.log('message: ' + JSON.stringify(msg)); + console.log('data: ' + this.wallet); - this.attachIcon(this.wallet.offline_summary.BTC); - this.attachIcon(this.wallet.offline_summary.ETH); - this.attachIcon(this.wallet.offline_summary.LTC); + if (this.wallet != null && this.wallet.coin_totals != null) { + this.attachIcon(this.wallet.coin_totals); + this.attachIcon(this.wallet.coins_offline); + this.attachIcon(this.wallet.coins_online); - this.attachIcon(this.wallet.online_summary.BTC); - this.attachIcon(this.wallet.online_summary.ETH); - this.attachIcon(this.wallet.online_summary.LTC); + this.attachIcon(this.wallet.offline_summary.BTC); + this.attachIcon(this.wallet.offline_summary.ETH); + this.attachIcon(this.wallet.offline_summary.LTC); + + this.attachIcon(this.wallet.online_summary.BTC); + this.attachIcon(this.wallet.online_summary.ETH); + this.attachIcon(this.wallet.online_summary.LTC); + } } }); } diff --git a/web/src/app/services/websocket-response-handler/websocket-response-handler.service.ts b/web/src/app/services/websocket-response-handler/websocket-response-handler.service.ts index 66aa1ba6..4618cf65 100644 --- a/web/src/app/services/websocket-response-handler/websocket-response-handler.service.ts +++ b/web/src/app/services/websocket-response-handler/websocket-response-handler.service.ts @@ -25,8 +25,12 @@ export class WebsocketResponseHandlerService { this.isConnected = this.ws.isConnected; }, 2000); const websocketResponseMessage = JSON.parse(response.data); - const websocketResponseData = websocketResponseMessage.Data === undefined ? websocketResponseMessage.data : websocketResponseMessage.Data; - const websocketResponseEvent = websocketResponseMessage.Event === undefined ? websocketResponseMessage.event : websocketResponseMessage.Event; + const websocketResponseData = websocketResponseMessage.Data === undefined + ? websocketResponseMessage.data + : websocketResponseMessage.Data; + const websocketResponseEvent = websocketResponseMessage.Event === undefined + ? websocketResponseMessage.event + : websocketResponseMessage.Event; const responseMessage = new WebSocketMessage(); responseMessage.event = websocketResponseEvent; diff --git a/web/src/app/services/websocket/websocket.service.ts b/web/src/app/services/websocket/websocket.service.ts index 00538942..01a39f69 100644 --- a/web/src/app/services/websocket/websocket.service.ts +++ b/web/src/app/services/websocket/websocket.service.ts @@ -52,7 +52,7 @@ export class WebsocketService { }, 400); if (ws.readyState !== WebSocket.OPEN) { - new Error('Failed to send message to websocket after 10 attempts'); + throw new Error('Failed to send message to websocket after 10 attempts'); this.isConnected = false; } } diff --git a/web/src/app/shared/classes/config.ts b/web/src/app/shared/classes/config.ts index e007312a..fdeebe08 100644 --- a/web/src/app/shared/classes/config.ts +++ b/web/src/app/shared/classes/config.ts @@ -1,5 +1,11 @@ import { inherits } from 'util'; +export class CurrencyPairRedux { + Name: string; + ParsedName: string; + Enabled: boolean; +} + export class Config { Name: string; EncryptConfig?: number; @@ -113,11 +119,6 @@ export class Config { } } -export class CurrencyPairRedux { - Name: string; - ParsedName: string; - Enabled: boolean; - } export interface CurrencyPairFormat { Uppercase: boolean; diff --git a/web/src/app/shared/classes/websocket.ts b/web/src/app/shared/classes/websocket.ts index 12bee94a..26c2ebc3 100644 --- a/web/src/app/shared/classes/websocket.ts +++ b/web/src/app/shared/classes/websocket.ts @@ -1,3 +1,11 @@ +export class WebSocketMessageType { + public static Auth = 'auth'; + public static GetConfig = 'GetConfig'; + public static SaveConfig = 'SaveConfig'; + public static GetPortfolio = 'GetPortfolio'; + public static TickerUpdate = 'ticker_update'; +} + export class WebSocketMessage { public event: string; public data: any; @@ -23,11 +31,3 @@ export class WebSocketMessage { return response; } } - -export class WebSocketMessageType { - public static Auth = 'auth'; - public static GetConfig = 'GetConfig'; - public static SaveConfig = 'SaveConfig'; - public static GetPortfolio = 'GetPortfolio'; - public static TickerUpdate = 'ticker_update'; -} diff --git a/web/src/app/shared/my-orders/my-orders.component.ts b/web/src/app/shared/my-orders/my-orders.component.ts index b8e9be63..da148866 100644 --- a/web/src/app/shared/my-orders/my-orders.component.ts +++ b/web/src/app/shared/my-orders/my-orders.component.ts @@ -1,5 +1,12 @@ import { Component, OnInit } from '@angular/core'; +export class MyOrders { + public count: number; + public total: number; + public price: number; + public amount: number; +} + @Component({ selector: 'app-my-orders', templateUrl: './my-orders.component.html', @@ -25,11 +32,3 @@ export class MyOrdersComponent implements OnInit { this.orders.push(item); } } - - -export class MyOrders { - public count: number; - public total: number; - public price: number; - public amount: number; -} diff --git a/web/src/app/shared/orders/orders.component.ts b/web/src/app/shared/orders/orders.component.ts index ab95e237..a367d0c0 100644 --- a/web/src/app/shared/orders/orders.component.ts +++ b/web/src/app/shared/orders/orders.component.ts @@ -1,5 +1,12 @@ import { Component, OnInit } from '@angular/core'; +export class Order { + public count: number; + public total: number; + public price: number; + public amount: number; +} + @Component({ selector: 'app-orders', templateUrl: './orders.component.html', @@ -49,11 +56,3 @@ export class OrdersComponent implements OnInit { } } - - -export class Order { - public count: number; - public total: number; - public price: number; - public amount: number; -} diff --git a/web/src/app/shared/theme-picker/theme-picker.component.ts b/web/src/app/shared/theme-picker/theme-picker.component.ts index d1c461fc..a85a9f76 100644 --- a/web/src/app/shared/theme-picker/theme-picker.component.ts +++ b/web/src/app/shared/theme-picker/theme-picker.component.ts @@ -11,7 +11,6 @@ import {CommonModule} from '@angular/common'; styleUrls: ['theme-picker.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, - host: {'aria-hidden': 'true'}, }) export class ThemePickerComponent { currentTheme; diff --git a/web/src/app/shared/trade-history/trade-history.component.ts b/web/src/app/shared/trade-history/trade-history.component.ts index a6032c15..f23b1d82 100644 --- a/web/src/app/shared/trade-history/trade-history.component.ts +++ b/web/src/app/shared/trade-history/trade-history.component.ts @@ -1,5 +1,11 @@ import { Component, OnInit } from '@angular/core'; +export class TradeHistoryOrder { + public price: number; + public time: Date; + public amount: number; +} + @Component({ selector: 'app-trade-history', templateUrl: './trade-history.component.html', @@ -45,12 +51,4 @@ export class TradeHistoryComponent implements OnInit { this.orders.push(item); this.orders.push(item); } - - - -} -export class TradeHistoryOrder { - public price: number; - public time: Date; - public amount: number; } diff --git a/web/src/polyfills.ts b/web/src/polyfills.ts index ca823550..958104bd 100644 --- a/web/src/polyfills.ts +++ b/web/src/polyfills.ts @@ -30,7 +30,7 @@ // import 'core-js/es6/date'; // import 'core-js/es6/array'; // import 'core-js/es6/regexp'; - import 'core-js/es6/map'; +// import 'core-js/es6/map'; // import 'core-js/es6/set'; /** IE10 and IE11 requires the following for NgClass support on SVG elements */ @@ -41,8 +41,8 @@ /** Evergreen browsers require these. **/ -import 'core-js/es6/reflect'; -import 'core-js/es7/reflect'; +// import 'core-js/es6/reflect'; +// import 'core-js/es7/reflect'; /** ALL Firefox browsers require the following to support `@angular/animation`. **/ diff --git a/web/src/tsconfig.spec.json b/web/src/tsconfig.spec.json index f8ac26e3..d3092415 100644 --- a/web/src/tsconfig.spec.json +++ b/web/src/tsconfig.spec.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../out-tsc/spec", "module": "commonjs", - "target": "es2015", + "target": "es5", "baseUrl": "", "types": [ "jasmine", diff --git a/web/tsconfig.json b/web/tsconfig.json index b476526f..1a0c944e 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -7,13 +7,12 @@ "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, - "target": "es6", + "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2017", - "es2015", "dom", ] } diff --git a/web/tslint.json b/web/tslint.json index eef4395e..17846812 100644 --- a/web/tslint.json +++ b/web/tslint.json @@ -22,8 +22,7 @@ "eofline": true, "forin": true, "import-blacklist": [ - true, - "rxjs/Rx" + true ], "import-spacing": true, "indent": [