Skip to content

Commit 331bf35

Browse files
Add TSLint rule file and fix all violations (#1381)
1 parent f08da32 commit 331bf35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1106
-911
lines changed

client-ts/FunctionalTests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
},
1111
"scripts": {
1212
"clean": "node ../node_modules/rimraf/bin.js ./wwwroot/dist",
13-
"build": "npm run build:tsc && npm run build:rollup",
13+
"build": "npm run build:lint && npm run build:tsc && npm run build:rollup",
14+
"build:lint": "node ../node_modules/tslint/bin/tslint -c ../tslint.json -p ./tsconfig.json",
1415
"build:tsc": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json",
1516
"build:rollup": "node ../node_modules/rollup/bin/rollup -c"
1617
},
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { TransportType, IHubProtocol, JsonHubProtocol } from "@aspnet/signalr"
5-
import { MessagePackHubProtocol } from "@aspnet/signalr-protocol-msgpack"
4+
import { IHubProtocol, JsonHubProtocol, TransportType } from "@aspnet/signalr";
5+
import { MessagePackHubProtocol } from "@aspnet/signalr-protocol-msgpack";
66

77
export const ECHOENDPOINT_URL = "http://" + document.location.host + "/echo";
88

99
export function getTransportTypes(): TransportType[] {
10-
var transportTypes = [];
10+
const transportTypes = [];
1111
if (typeof WebSocket !== "undefined") {
1212
transportTypes.push(TransportType.WebSockets);
1313
}
@@ -20,13 +20,13 @@ export function getTransportTypes(): TransportType[] {
2020
}
2121

2222
export function eachTransport(action: (transport: TransportType) => void) {
23-
getTransportTypes().forEach(function (t) {
23+
getTransportTypes().forEach((t) => {
2424
return action(t);
2525
});
2626
}
2727

2828
export function eachTransportAndProtocol(action: (transport: TransportType, protocol: IHubProtocol) => void) {
29-
var protocols : IHubProtocol[] = [new JsonHubProtocol()];
29+
const protocols: IHubProtocol[] = [new JsonHubProtocol()];
3030
// IE9 does not support XmlHttpRequest advanced features so disable for now
3131
// This can be enabled if we fix: https://github.com/aspnet/SignalR/issues/742
3232
if (typeof new XMLHttpRequest().responseType === "string") {
@@ -35,9 +35,9 @@ export function eachTransportAndProtocol(action: (transport: TransportType, prot
3535
// Everything works fine in the module
3636
protocols.push(new MessagePackHubProtocol());
3737
}
38-
getTransportTypes().forEach(function (t) {
39-
return protocols.forEach(function (p) {
38+
getTransportTypes().forEach((t) => {
39+
return protocols.forEach((p) => {
4040
return action(t, p);
4141
});
4242
});
43-
}
43+
}

client-ts/FunctionalTests/ts/ConnectionTests.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { HttpConnection, LogLevel, TransportType } from "@aspnet/signalr"
5-
import { eachTransport, ECHOENDPOINT_URL } from "./Common"
4+
import { HttpConnection, LogLevel, TransportType } from "@aspnet/signalr";
5+
import { eachTransport, ECHOENDPOINT_URL } from "./Common";
66

7-
describe('connection', function () {
8-
if (typeof WebSocket !== 'undefined') {
9-
it("can connect to the server without specifying transport explicitly", function (done) {
10-
var message = "Hello World!";
11-
var connection = new HttpConnection(ECHOENDPOINT_URL);
7+
describe("connection", () => {
8+
if (typeof WebSocket !== "undefined") {
9+
it("can connect to the server without specifying transport explicitly", (done) => {
10+
const message = "Hello World!";
11+
const connection = new HttpConnection(ECHOENDPOINT_URL);
1212

13-
var received = "";
14-
connection.onreceive = function (data) {
13+
let received = "";
14+
connection.onreceive = (data) => {
1515
received += data;
16-
if (data == message) {
16+
if (data === message) {
1717
connection.stop();
1818
}
1919
};
2020

21-
connection.onclose = function (error) {
21+
connection.onclose = (error) => {
2222
expect(error).toBeUndefined();
2323
done();
2424
};
2525

26-
connection.start().then(function () {
26+
connection.start().then(() => {
2727
connection.send(message);
28-
}).catch(function (e) {
28+
}).catch((e) => {
2929
fail();
3030
done();
3131
});
3232
});
3333
}
3434

35-
eachTransport(function (transportType) {
36-
it("over " + TransportType[transportType] + " can send and receive messages", function (done) {
37-
var message = "Hello World!";
35+
eachTransport((transportType) => {
36+
it("over " + TransportType[transportType] + " can send and receive messages", (done) => {
37+
const message = "Hello World!";
3838
// the url should be resolved relative to the document.location.host
3939
// and the leading '/' should be automatically added to the url
40-
var connection = new HttpConnection("echo", {
40+
const connection = new HttpConnection("echo", {
41+
logger: LogLevel.Trace,
4142
transport: transportType,
42-
logger: LogLevel.Trace
4343
});
4444

45-
var received = "";
46-
connection.onreceive = function (data) {
45+
let received = "";
46+
connection.onreceive = (data) => {
4747
received += data;
48-
if (data == message) {
48+
if (data === message) {
4949
connection.stop();
5050
}
5151
};
5252

53-
connection.onclose = function (error) {
53+
connection.onclose = (error) => {
5454
expect(error).toBeUndefined();
5555
done();
5656
};
5757

58-
connection.start().then(function () {
58+
connection.start().then(() => {
5959
connection.send(message);
60-
}).catch(function (e) {
60+
}).catch((e) => {
6161
fail();
6262
done();
6363
});

0 commit comments

Comments
 (0)