Skip to content

Commit

Permalink
Apply TS formatter and linter to workspace-loader (eclipse-che#13532)
Browse files Browse the repository at this point in the history
* Added linter and formatter for Typescript.

Signed-off-by: Oleksii Kurinnyi <[email protected]>

* Fixed linting warnings.

Signed-off-by: Oleksii Kurinnyi <[email protected]>

* Fixed formatting.

Signed-off-by: Oleksii Kurinnyi <[email protected]>
  • Loading branch information
akurinnoy authored Jun 21, 2019
1 parent 5f76543 commit 644eb14
Show file tree
Hide file tree
Showing 17 changed files with 879 additions and 714 deletions.
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"build": "webpack --config webpack.prod.js",
"start": "webpack-dev-server --open --config webpack.dev.js"
"compile": "webpack --config webpack.prod.js",
"start": "webpack-dev-server --open --config webpack.dev.js",
"format": "tsfmt -r --useTsfmt tsfmt.json",
"lint:fix": "tslint -c tslint.json --fix --project .",
"build": "yarn run format && yarn run compile"
},
"author": "",
"license": "EPL-1.0",
Expand All @@ -20,14 +23,18 @@
"mini-css-extract-plugin": "^0.5.0",
"style-loader": "^0.20.1",
"ts-loader": "^5.3.3",
"tslint": "5.9.1",
"tslint-loader": "^3.5.4",
"typescript": "^2.7.1",
"typescript-formatter": "7.2.2",
"uglifyjs-webpack-plugin": "^1.1.8",
"webpack": "^4.0.0",
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.1.11",
"webpack-merge": "^4.1.1"
},
"dependencies": {
"@eclipse-che/api": "^7.0.0-beta-4.0-80162ea6d2",
"lodash": "4.17.11",
"reconnecting-websocket": "3.2.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ declare namespace che {
properties?: any;
attributes?: {
[attrName: string]: string | number;
};
};
}

export interface IEnvironmentMachineVolume {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import { WorkspaceLoader } from './workspace-loader';

/** Initialize */
if (document.getElementById('workspace-console')) {
new KeycloakLoader().loadKeycloakSettings().catch((error: any) => {
new KeycloakLoader().loadKeycloakSettings().catch(error => {
if (error) {
console.log(error);
}
}).then((keycloak: any) => {
}).then(keycloak => {
new WorkspaceLoader(new Loader(), keycloak).load();
});
}
123 changes: 64 additions & 59 deletions src/json-rpc/che-json-rpc-api-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {ICommunicationClient, JsonRpcClient} from './json-rpc-client';

import { ICommunicationClient, JsonRpcClient } from './json-rpc-client';

// tslint:disable:no-any

export class IChannel {
subscription: string;
unsubscription: string;
notification: string;
subscription: string;
unsubscription: string;
notification: string;
}

/**
Expand All @@ -24,64 +27,66 @@ export class IChannel {
* @author Ann Shumilova
*/
export class CheJsonRpcApiClient {
/**
* Client that implements JSON RPC protocol.
*/
private jsonRpcClient: JsonRpcClient;
/**
* Communication client (can be http, websocket).
*/
private client: ICommunicationClient;
/**
* Client that implements JSON RPC protocol.
*/
private jsonRpcClient: JsonRpcClient;
/**
* Communication client (can be http, websocket).
*/
private client: ICommunicationClient;

constructor (client: ICommunicationClient) {
this.client = client;
this.jsonRpcClient = new JsonRpcClient(client);
}
constructor(client: ICommunicationClient) {
this.client = client;
this.jsonRpcClient = new JsonRpcClient(client);
}

/**
* Subscribe on the events from service.
*
* @param event event's name to subscribe
* @param notification notification name to handle
* @param handler event's handler
* @param params params (optional)
*/
subscribe(event: string, notification: string, handler: Function, params?: any): void {
this.jsonRpcClient.addNotificationHandler(notification, handler);
this.jsonRpcClient.notify(event, params);
}
/**
* Subscribe on the events from service.
*
* @param event event's name to subscribe
* @param notification notification name to handle
* @param handler event's handler
* @param params params (optional)
*/
/* tslint:disable-next-line:no-any */
subscribe(event: string, notification: string, handler: Function, params?: any): void {
this.jsonRpcClient.addNotificationHandler(notification, handler);
this.jsonRpcClient.notify(event, params);
}

/**
* Unsubscribe concrete handler from events from service.
*
* @param event event's name to unsubscribe
* @param notification notification name binded to the event
* @param handler handler to be removed
* @param params params (optional)
*/
unsubscribe(event: string, notification: string, handler: Function, params?: any): void {
this.jsonRpcClient.removeNotificationHandler(notification, handler);
this.jsonRpcClient.notify(event, params);
}
/**
* Unsubscribe concrete handler from events from service.
*
* @param event event's name to unsubscribe
* @param notification notification name binded to the event
* @param handler handler to be removed
* @param params params (optional)
*/
/* tslint:disable-next-line:no-any */
unsubscribe(event: string, notification: string, handler: Function, params?: any): void {
this.jsonRpcClient.removeNotificationHandler(notification, handler);
this.jsonRpcClient.notify(event, params);
}

/**
* Connects to the pointed entrypoint
*
* @param entrypoint entrypoint to connect to
* @returns {Promise<any>} promise
*/
connect(entrypoint: () => string): Promise<any> {
return this.client.connect(entrypoint);
}
/**
* Connects to the pointed entrypoint
*
* @param entrypoint entrypoint to connect to
* @returns {Promise<void>} promise
*/
connect(entrypoint: () => string): Promise<void> {
return this.client.connect(entrypoint);
}

/**
* Makes request.
*
* @param method
* @param params
* @returns {ng.IPromise<any>}
*/
request(method: string, params?: any): Promise<any> {
return this.jsonRpcClient.request(method, params);
}
/**
* Makes request.
*
* @param method
* @param params
* @returns {Promise<any>}
*/
request(method: string, params?: any): Promise<any> {
return this.jsonRpcClient.request(method, params);
}
}
Loading

0 comments on commit 644eb14

Please sign in to comment.