Skip to content

Commit 130e2b8

Browse files
Nicolas ERNYJulien-Molina
authored andcommitted
Configure prettier (#149)
1 parent 03a93d8 commit 130e2b8

30 files changed

Lines changed: 1223 additions & 813 deletions

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"tabWidth": 4,
4+
"printWidth": 120
5+
}

package.json

Lines changed: 106 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,110 @@
11
{
2-
"name": "reactivexcomponent.js",
3-
"version": "3.1.9",
4-
"description": "Javascript reactive client API for XComponent",
5-
"main": "dist/index.js",
6-
"types": "dist/index.d.ts",
7-
"directories": {
8-
"test": "test",
9-
"lib": "./lib"
10-
},
11-
"scripts": {
12-
"build": "node scripts/clean.js && tsc",
13-
"watch": "node scripts/clean.js && tsc -w",
14-
"test": "node scripts/test.js --env=jsdom",
15-
"coverage": "node scripts/test.js --env=jsdom --coverage",
16-
"coveralls": "cat ./coverage/lcov.info | node node_modules/.bin/coveralls",
17-
"lint": "tslint -c tslint.json 'src/**/*.{ts,tsx}'"
18-
},
19-
"jest": {
20-
"setupTestFrameworkScriptFile": "<rootDir>/config/jest/setup.js",
21-
"collectCoverageFrom": [
22-
"src/**/*.{js,jsx,ts,tsx}"
23-
],
24-
"testMatch": [
25-
"<rootDir>/src/**/?(*.)(test).ts?(x)"
26-
],
27-
"testEnvironment": "node",
28-
"testURL": "http://localhost",
29-
"transform": {
30-
"^.+\\.tsx?$": "<rootDir>/config/jest/typescriptTransform.js",
31-
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
32-
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
2+
"name": "reactivexcomponent.js",
3+
"version": "3.1.9",
4+
"description": "Javascript reactive client API for XComponent",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"directories": {
8+
"test": "test",
9+
"lib": "./lib"
10+
},
11+
"scripts": {
12+
"build": "node scripts/clean.js && tsc",
13+
"watch": "node scripts/clean.js && tsc -w",
14+
"test": "node scripts/test.js --env=jsdom",
15+
"coverage": "node scripts/test.js --env=jsdom --coverage",
16+
"coveralls": "cat ./coverage/lcov.info | node node_modules/.bin/coveralls",
17+
"lint": "tslint -c tslint.json 'src/**/*.{ts,tsx}'"
18+
},
19+
"jest": {
20+
"setupTestFrameworkScriptFile": "<rootDir>/config/jest/setup.js",
21+
"collectCoverageFrom": [
22+
"src/**/*.{js,jsx,ts,tsx}"
23+
],
24+
"testMatch": [
25+
"<rootDir>/src/**/?(*.)(test).ts?(x)"
26+
],
27+
"testEnvironment": "node",
28+
"testURL": "http://localhost",
29+
"transform": {
30+
"^.+\\.tsx?$": "<rootDir>/config/jest/typescriptTransform.js",
31+
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
32+
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
33+
},
34+
"transformIgnorePatterns": [
35+
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$"
36+
],
37+
"moduleFileExtensions": [
38+
"mjs",
39+
"web.ts",
40+
"ts",
41+
"web.tsx",
42+
"tsx",
43+
"web.js",
44+
"js",
45+
"web.jsx",
46+
"jsx",
47+
"json",
48+
"node"
49+
]
3350
},
34-
"transformIgnorePatterns": [
35-
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$"
51+
"repository": {
52+
"type": "git",
53+
"url": "git+https://github.com/xcomponent/ReactiveXComponent.js.git"
54+
},
55+
"keywords": [
56+
"xcomponent",
57+
"api",
58+
"javascript",
59+
"websocket"
3660
],
37-
"moduleFileExtensions": [
38-
"mjs",
39-
"web.ts",
40-
"ts",
41-
"web.tsx",
42-
"tsx",
43-
"web.js",
44-
"js",
45-
"web.jsx",
46-
"jsx",
47-
"json",
48-
"node"
49-
]
50-
},
51-
"repository": {
52-
"type": "git",
53-
"url": "git+https://github.com/xcomponent/ReactiveXComponent.js.git"
54-
},
55-
"keywords": [
56-
"xcomponent",
57-
"api",
58-
"javascript",
59-
"websocket"
60-
],
61-
"author": "XComponent <dev@xcomponent.com> (http://www.xcomponent.com)",
62-
"license": "Apache-2.0",
63-
"bugs": {
64-
"url": "https://github.com/xcomponent/ReactiveXComponent.js/issues"
65-
},
66-
"homepage": "https://github.com/xcomponent/ReactiveXComponent.js",
67-
"dependencies": {
68-
"@types/es6-shim": "^0.31.32",
69-
"@types/jest": "^23.0.0",
70-
"@types/node": "^10.0.0",
71-
"@types/pako": "^1.0.0",
72-
"@types/rx": "^4.1.1",
73-
"@types/xml2js": "0.4.3",
74-
"@types/xmldom": "^0.1.28",
75-
"atob": "^2.0.3",
76-
"log4ts": "^0.4.2",
77-
"pako": "^1.0.3",
78-
"rxjs": "^6.0.0",
79-
"rxjs-compat": "^6",
80-
"uuid": "^3.0.1",
81-
"websocket": "^1.0.25",
82-
"xml2js": "^0.4.17"
83-
},
84-
"devDependencies": {
85-
"clean-webpack-plugin": "^0.1.14",
86-
"compression": "^1.6.2",
87-
"jest": "^23.0.0",
88-
"jest-cli": "^23.0.0",
89-
"json-loader": "^0.5.4",
90-
"mock-socket": "^8.0.1",
91-
"source-map-loader": "^0.2.0",
92-
"ts-jest": "^23.0.0",
93-
"ts-loader": "^4.0.0",
94-
"ts-mockito": "^2.3.0",
95-
"tslint": "^5.0.0",
96-
"tslint-config-prettier": "^1.14.0",
97-
"tslint-loader": "^3.6.0",
98-
"tslint-plugin-prettier": "^1.3.0",
99-
"tslint-react": "^3.6.0",
100-
"typescript": "^3.0.1"
101-
}
61+
"author": "XComponent <dev@xcomponent.com> (http://www.xcomponent.com)",
62+
"license": "Apache-2.0",
63+
"bugs": {
64+
"url": "https://github.com/xcomponent/ReactiveXComponent.js/issues"
65+
},
66+
"homepage": "https://github.com/xcomponent/ReactiveXComponent.js",
67+
"dependencies": {
68+
"@types/es6-shim": "^0.31.32",
69+
"@types/jest": "^23.0.0",
70+
"@types/node": "^10.0.0",
71+
"@types/pako": "^1.0.0",
72+
"@types/rx": "^4.1.1",
73+
"@types/xml2js": "0.4.3",
74+
"@types/xmldom": "^0.1.28",
75+
"atob": "^2.0.3",
76+
"log4ts": "^0.4.2",
77+
"pako": "^1.0.3",
78+
"rxjs": "^6.0.0",
79+
"rxjs-compat": "^6",
80+
"uuid": "^3.0.1",
81+
"websocket": "^1.0.25",
82+
"xml2js": "^0.4.17"
83+
},
84+
"devDependencies": {
85+
"clean-webpack-plugin": "^0.1.14",
86+
"compression": "^1.6.2",
87+
"husky": "^1.0.0-rc.13",
88+
"jest": "^23.0.0",
89+
"jest-cli": "^23.0.0",
90+
"json-loader": "^0.5.4",
91+
"mock-socket": "^8.0.1",
92+
"prettier": "^1.14.0",
93+
"pretty-quick": "^1.6.0",
94+
"source-map-loader": "^0.2.0",
95+
"ts-jest": "^23.0.0",
96+
"ts-loader": "^4.0.0",
97+
"ts-mockito": "^2.3.0",
98+
"tslint": "^5.0.0",
99+
"tslint-config-prettier": "^1.14.0",
100+
"tslint-loader": "^3.6.0",
101+
"tslint-plugin-prettier": "^1.3.0",
102+
"tslint-react": "^3.6.0",
103+
"typescript": "^3.0.1"
104+
},
105+
"husky": {
106+
"hooks": {
107+
"pre-commit": "pretty-quick --staged"
108+
}
109+
}
102110
}

src/communication/Utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export class Utils {
44
if (index > -1) {
55
array.splice(index, 1);
66
} else {
7-
throw new Error("Element to remove not found");
7+
throw new Error('Element to remove not found');
88
}
99
}
10-
}
10+
}
Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {fromEvent as observableFromEvent, Observable } from "rxjs";
2-
import {filter, first, map, takeWhile} from "rxjs/operators";
3-
import { Commands } from "../configuration/xcWebSocketBridgeConfiguration";
4-
import { CompositionModel, DeserializedData, Serializer, Deserializer } from "./xcomponentMessages";
5-
import "rxjs/add/observable/fromEvent";
6-
import { Logger } from "log4ts";
7-
import { DefaultApiConfigurationParser } from "../configuration/apiConfigurationParser";
8-
import { ApiConfiguration } from "../configuration/apiConfiguration";
1+
import { fromEvent as observableFromEvent, Observable } from 'rxjs';
2+
import { filter, first, map, takeWhile } from 'rxjs/operators';
3+
import { Commands } from '../configuration/xcWebSocketBridgeConfiguration';
4+
import { CompositionModel, DeserializedData, Serializer, Deserializer } from './xcomponentMessages';
5+
import 'rxjs/add/observable/fromEvent';
6+
import { Logger } from 'log4ts';
7+
import { DefaultApiConfigurationParser } from '../configuration/apiConfigurationParser';
8+
import { ApiConfiguration } from '../configuration/apiConfiguration';
99

1010
export class WebSocketBridgeCommunication {
11-
private logger: Logger = Logger.getLogger("HeartbeatManager");
11+
private logger: Logger = Logger.getLogger('HeartbeatManager');
1212
private updates$: Observable<DeserializedData>;
1313
private deserializer: Deserializer;
1414
private serializer: Serializer;
@@ -19,18 +19,21 @@ export class WebSocketBridgeCommunication {
1919
this.deserializer = new Deserializer();
2020
this.serializer = new Serializer();
2121
let thisWebSocketBridgeCommunication = this;
22-
this.updates$ = observableFromEvent(this.webSocket, "message").pipe(
22+
this.updates$ = observableFromEvent(this.webSocket, 'message').pipe(
2323
takeWhile((rawMessage: MessageEvent) => this.runnning),
24-
map((rawMessage: MessageEvent) => thisWebSocketBridgeCommunication.deserializer.deserializeWithoutTopic(rawMessage.data || rawMessage)));
24+
map((rawMessage: MessageEvent) =>
25+
thisWebSocketBridgeCommunication.deserializer.deserializeWithoutTopic(rawMessage.data || rawMessage)
26+
)
27+
);
2528
}
2629

2730
public startHeartbeat(heartbeatIntervalSeconds: number): void {
2831
let thisWebSocketBridgeCommunication = this;
2932
let command = Commands[Commands.hb];
30-
this.updates$.pipe(
31-
filter((data: DeserializedData) => data.command === command))
33+
this.updates$
34+
.pipe(filter((data: DeserializedData) => data.command === command))
3235
.subscribe((data: DeserializedData) => {
33-
this.logger.trace("Heartbeat received successfully");
36+
this.logger.trace('Heartbeat received successfully');
3437
});
3538
let commandData = {
3639
Command: command,
@@ -39,32 +42,36 @@ export class WebSocketBridgeCommunication {
3942
let input = thisWebSocketBridgeCommunication.serializer.convertCommandDataToWebsocketInputFormat(commandData);
4043
this.heartbeatTimer = setInterval(() => {
4144
thisWebSocketBridgeCommunication.webSocket.send(input);
42-
this.logger.trace("Heartbeat sent");
45+
this.logger.trace('Heartbeat sent');
4346
}, heartbeatIntervalSeconds * 1000);
4447
}
4548

4649
public getCompositionModel(apiName: string): Promise<CompositionModel> {
4750
const thisWebSocketBridgeCommunication = this;
4851
const command = Commands[Commands.getModel];
49-
const promise = this.updates$.pipe(
50-
filter((data: DeserializedData) => data.command === command),
51-
first(),
52-
map((data: DeserializedData) => {
53-
return thisWebSocketBridgeCommunication.deserializer.getJsonDataFromGetModelRequest(data.stringData);
54-
}))
52+
const promise = this.updates$
53+
.pipe(
54+
filter((data: DeserializedData) => data.command === command),
55+
first(),
56+
map((data: DeserializedData) => {
57+
return thisWebSocketBridgeCommunication.deserializer.getJsonDataFromGetModelRequest(
58+
data.stringData
59+
);
60+
})
61+
)
5562
.toPromise()
5663
.then((compositionModel: CompositionModel | undefined) => {
5764
if (!compositionModel) {
58-
const errorMessage = "Model " + apiName + " not found";
65+
const errorMessage = 'Model ' + apiName + ' not found';
5966
this.logger.error(errorMessage);
6067
throw new Error(errorMessage);
6168
}
62-
this.logger.info("Model " + apiName + " received successfully");
69+
this.logger.info('Model ' + apiName + ' received successfully');
6370
return compositionModel;
6471
});
6572
const commandData = {
6673
Command: command,
67-
Data: { "Name": apiName }
74+
Data: { Name: apiName }
6875
};
6976
const input = thisWebSocketBridgeCommunication.serializer.convertCommandDataToWebsocketInputFormat(commandData);
7077
this.webSocket.send(input);
@@ -74,32 +81,40 @@ export class WebSocketBridgeCommunication {
7481
public getXcApiList(): Promise<Array<string>> {
7582
const thisWebSocketBridgeCommunication = this;
7683
const command = Commands[Commands.getXcApiList];
77-
const promise = this.updates$.pipe(
78-
filter((data: DeserializedData) => data.command === command),
79-
first(),
80-
map((data: DeserializedData) => {
81-
this.logger.info("ApiList received successfully");
82-
return thisWebSocketBridgeCommunication.deserializer.getJsonDataFromGetXcApiListRequest(data.stringData);
83-
}))
84+
const promise = this.updates$
85+
.pipe(
86+
filter((data: DeserializedData) => data.command === command),
87+
first(),
88+
map((data: DeserializedData) => {
89+
this.logger.info('ApiList received successfully');
90+
return thisWebSocketBridgeCommunication.deserializer.getJsonDataFromGetXcApiListRequest(
91+
data.stringData
92+
);
93+
})
94+
)
8495
.toPromise();
8596
const commandData = {
8697
Command: command,
8798
Data: {}
8899
};
89-
this.webSocket.send(thisWebSocketBridgeCommunication.serializer.convertCommandDataToWebsocketInputFormat(commandData));
100+
this.webSocket.send(
101+
thisWebSocketBridgeCommunication.serializer.convertCommandDataToWebsocketInputFormat(commandData)
102+
);
90103
return promise;
91104
}
92105

93106
public getXcApiConfiguration(apiName: string): Promise<ApiConfiguration> {
94107
const thisWebSocketBridgeCommunication = this;
95108
const command = Commands[Commands.getXcApi];
96-
const promise = this.updates$.pipe(
97-
filter((data: DeserializedData) => data.command === command),
98-
first(),
99-
map((data: DeserializedData) => {
100-
this.logger.info(apiName + " " + "received successfully");
101-
return thisWebSocketBridgeCommunication.deserializer.getJsonDataFromXcApiRequest(data.stringData);
102-
}))
109+
const promise = this.updates$
110+
.pipe(
111+
filter((data: DeserializedData) => data.command === command),
112+
first(),
113+
map((data: DeserializedData) => {
114+
this.logger.info(apiName + ' ' + 'received successfully');
115+
return thisWebSocketBridgeCommunication.deserializer.getJsonDataFromXcApiRequest(data.stringData);
116+
})
117+
)
103118
.toPromise()
104119
.then((xcApi: string | undefined) => {
105120
if (!xcApi) {
@@ -114,12 +129,14 @@ export class WebSocketBridgeCommunication {
114129
Command: command,
115130
Data: { Name: apiName }
116131
};
117-
this.webSocket.send(thisWebSocketBridgeCommunication.serializer.convertCommandDataToWebsocketInputFormat(commandData));
132+
this.webSocket.send(
133+
thisWebSocketBridgeCommunication.serializer.convertCommandDataToWebsocketInputFormat(commandData)
134+
);
118135
return promise;
119136
}
120137

121138
public dispose(): void {
122139
clearInterval(this.heartbeatTimer);
123140
this.runnning = false;
124141
}
125-
}
142+
}

0 commit comments

Comments
 (0)