Skip to content

Commit fcf7ac2

Browse files
committed
feat: added tslint to the mixture
1 parent c02e169 commit fcf7ac2

File tree

7 files changed

+229
-15
lines changed

7 files changed

+229
-15
lines changed

package-lock.json

Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
"version": "0.4.1",
44
"description": "WebSocket client that consumes an API wrapping OpenAI Gym or gym-like environments such as Gym Retro or Unity ML-Agents.",
55
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
67
"scripts": {
78
"preinstall": "pip install -r requirements.txt",
89
"prebuild": "rm -rf dist",
910
"build": "tsc",
10-
"postinstall": "npm run build",
11+
"predocs": "rm -rf docs",
12+
"docs": "typedoc",
13+
"lint": "tslint src/**/*.ts",
1114
"start-server": "python -m gymie &",
1215
"kill-server": "./shutdown.sh",
1316
"test-gymie": "ts-node src/Gymie.test.ts",
@@ -29,8 +32,7 @@
2932
"prerun-action-sample": "npm run start-server",
3033
"run-action-sample": "ts-node examples/actionSample.ts",
3134
"postrun-action-sample": "npm run kill-server 5000",
32-
"predocs": "rm -rf docs",
33-
"docs": "typedoc"
35+
"prepublish": "npm run build && npm run lint"
3436
},
3537
"repository": {
3638
"type": "git",
@@ -57,6 +59,7 @@
5759
"@types/yargs": "^15.0.8",
5860
"tape": "^5.0.1",
5961
"ts-node": "^9.0.0",
62+
"tslint": "^6.1.3",
6063
"typedoc": "^0.19.2",
6164
"typescript": "^4.0.3"
6265
},

src/Deferred.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ type PromiseReject = (reason?: any) => void
1111
/**
1212
* Returns an object with a promise on the way and two methods,
1313
* `resolve()` and `reject()`, to change its state.
14-
* @see {@link https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred Deferred object}
14+
* @see {@link https://mzl.la/34i6vXn Deferred object}
1515
* @typeParam T Data wrapped in the promise.
1616
*/
1717
export default class Deferred<T> {
1818

1919
/**
2020
* Changes the state of the promise to `resolved`
21-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve Promise.resolve()}
21+
* @see {@link https://mzl.la/3johZwY Promise.resolve()}
2222
*/
2323
resolve: PromiseResolve<T> = null
2424

2525
/**
2626
* Changes the state of the promise to `rejected`
27-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject Promise.reject()}
27+
* @see {@link https://mzl.la/2TbqLDw Promise.reject()}
2828
*/
2929
reject: PromiseReject = null
3030
promise: Promise<T> = null

src/Gymie.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class Gymie {
3030

3131
/**
3232
* Callback function wrapping the socket's sending mechanism.
33-
* See {@link https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketConnection.md#sendutfstring WebSocketConnection#sendUTF}
33+
* See {@link https://bit.ly/3kjFcBp WebSocketConnection#sendUTF}
3434
* @param cmd Command to be sent to the server.
3535
*/
3636
sender = (cmd: Command) => {
@@ -39,7 +39,7 @@ export default class Gymie {
3939

4040
/**
4141
* Callback function for `message` event. Resolves the promise of the incoming message.
42-
* See {@link https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketConnection.md#message WebSocketConnection.onmessage}
42+
* See {@link https://bit.ly/3m59QPB WebSocketConnection.onmessage}
4343
* @param message Message received from the server (plus type).
4444
*/
4545
onMessage = (message: IMessage) => {
@@ -48,7 +48,7 @@ export default class Gymie {
4848

4949
/**
5050
* Callback function for `error` event. Rejects the promise of the incoming message with {@link ConnectionError}.
51-
* See {@link https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketConnection.md#error WebSocketConnection.onerror}
51+
* See {@link https://bit.ly/2HjgWRs WebSocketConnection.onerror}
5252
* @param err Thrown exception.
5353
*/
5454
onError = (err: Error) => {
@@ -60,8 +60,8 @@ export default class Gymie {
6060

6161
/**
6262
* Callback function for `close` event. Rejects the promise of the incoming message with {@link ConnectionClosed}.
63-
* @see {@link https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketConnection.md#closereasoncode-description WebSocketConnection.onclose}
64-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes Status Codes}
63+
* @see {@link https://bit.ly/2HbUb2l WebSocketConnection.onclose}
64+
* @see {@link https://mzl.la/37qVPHV Status Codes}
6565
* @param code Close code sent by the server.
6666
* @param desc Reason why the server closed the connection.
6767
*/

src/errors.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
* Compilation of custom errors.
33
*/
44

5+
// tslint:disable:max-classes-per-file
56

67
/**
78
* Emitted when there is an error connecting to the remote host or the handshake response sent by the server is invalid.
8-
* @see {@link https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketClient.md#connectfailed WebSocketClient.onConnectionFailed}
9+
* @see {@link https://bit.ly/2TcFJcv WebSocketClient.onConnectionFailed}
910
*/
1011
export class ConnectFailed extends Error {
1112
name: string = 'ConnectFailed'
@@ -27,7 +28,7 @@ export class NoConnected extends Error {
2728

2829
/**
2930
* Emitted when the connection has been fully closed and the socket is no longer connected.
30-
* @see {@link https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketConnection.md#closereasoncode-description WebSocketConnection.onClose}
31+
* @see {@link https://bit.ly/3kiSePP WebSocketConnection.onClose}
3132
*/
3233
export class ConnectionClosed extends Error {
3334
name: string = 'ConnectionClosed'
@@ -38,7 +39,7 @@ export class ConnectionClosed extends Error {
3839

3940
/**
4041
* Emitted when there has been a socket error. If this occurs, a close event will also be emitted.
41-
* @see {@link https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketConnection.md#error WebSocketConnection.onError}
42+
* @see {@link https://bit.ly/31v9Wbw WebSocketConnection.onError}
4243
*/
4344
export class ConnectionError extends Error {
4445
name: string = 'ConnectionError'

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type Dict<T> = {[key: string]: T}
1111
/**
1212
* Empty function used as default value.
1313
*/
14-
export const noop = () => {}
14+
export const noop = () => { /* noop */ }
1515

1616
/**
1717
* Converts a JS value to a JSON string.

0 commit comments

Comments
 (0)