Skip to content

Commit

Permalink
Fix eslint for wps express (#17962)
Browse files Browse the repository at this point in the history
* Fix eslint for wps express

* fix format failure
  • Loading branch information
vicancy authored Oct 1, 2021
1 parent afff61b commit 0456250
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion sdk/web-pubsub/web-pubsub-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"integration-test:node": "echo skipped",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o webpubsub-express-lintReport.html || exit 0",
"lint": "eslint package.json api-extractor.json src test --ext .ts",
"pack": "npm pack 2>&1",
"test:browser": "echo \"Browser is not supported.\" && exit 0",
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
Expand Down
2 changes: 1 addition & 1 deletion sdk/web-pubsub/web-pubsub-express/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { IncomingMessage } from "http";
import { Message } from "cloudevents";

function isJsonObject(obj: any) {
function isJsonObject(obj: any): boolean {
return obj && typeof obj === "object" && !Array.isArray(obj);
}

Expand Down
36 changes: 18 additions & 18 deletions sdk/web-pubsub/web-pubsub-express/test/connect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ describe("Can handle connect event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleConnect: async (_, res) => {
res.fail(400);
handleConnect: async (_, response) => {
response.fail(400);
}
});
const process = dispatcher.processRequest(req, res);
Expand All @@ -108,8 +108,8 @@ describe("Can handle connect event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleConnect: async (_, res) => {
res.success();
handleConnect: async (_, response) => {
response.success();
}
});
const process = dispatcher.processRequest(req, res);
Expand All @@ -125,8 +125,8 @@ describe("Can handle connect event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleConnect: async (_, res) => {
res.success({ userId: "vic" });
handleConnect: async (_, response) => {
response.success({ userId: "vic" });
}
});
const process = dispatcher.processRequest(req, res);
Expand All @@ -142,12 +142,12 @@ describe("Can handle connect event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleConnect: async (_, res) => {
res.setState("key1", "val1");
res.setState("key2", "val2");
res.setState("key1", ["val3"]);
res.setState("key3", "");
res.success({ userId: "vic" });
handleConnect: async (_, response) => {
response.setState("key1", "val1");
response.setState("key2", "val2");
response.setState("key1", ["val3"]);
response.setState("key3", "");
response.success({ userId: "vic" });
}
});
const process = dispatcher.processRequest(req, res);
Expand Down Expand Up @@ -175,10 +175,10 @@ describe("Can handle connect event", function() {
});
buildRequest(req, "hub1", "conn1", undefined, states);
const dispatcher = new CloudEventsDispatcher("hub1", ["*"], {
handleConnect: (req, response) => {
assert.equal("val3", req.context.states["key1"][0]);
assert.equal("val2", req.context.states["key2"]);
assert.equal("", req.context.states["key3"]);
handleConnect: (request, response) => {
assert.equal("val3", request.context.states["key1"][0]);
assert.equal("val2", request.context.states["key2"]);
assert.equal("", request.context.states["key3"]);
response.success();
}
});
Expand All @@ -194,8 +194,8 @@ describe("Can handle connect event", function() {
const endSpy = sinon.spy(res, "end");
buildRequest(req, "hub1", "conn1", undefined, "");
const dispatcher = new CloudEventsDispatcher("hub1", ["*"], {
handleConnect: (req, response) => {
assert.deepEqual({}, req.context.states);
handleConnect: (request, response) => {
assert.deepEqual({}, request.context.states);
response.success();
}
});
Expand Down
32 changes: 16 additions & 16 deletions sdk/web-pubsub/web-pubsub-express/test/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ describe("Can handle user event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleUserEvent: async (_, res) => {
res.fail(500);
handleUserEvent: async (_, response) => {
response.fail(500);
}
});
const process = dispatcher.processRequest(req, res);
Expand All @@ -105,8 +105,8 @@ describe("Can handle user event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleUserEvent: async (_, res) => {
res.success();
handleUserEvent: async (_, response) => {
response.success();
}
});
const process = dispatcher.processRequest(req, res);
Expand All @@ -122,8 +122,8 @@ describe("Can handle user event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleUserEvent: async (_, res) => {
res.success("a");
handleUserEvent: async (_, response) => {
response.success("a");
}
});
const process = dispatcher.processRequest(req, res);
Expand All @@ -140,8 +140,8 @@ describe("Can handle user event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleUserEvent: async (_, res) => {
res.success("a", "text");
handleUserEvent: async (_, response) => {
response.success("a", "text");
}
});
const process = dispatcher.processRequest(req, res);
Expand All @@ -158,8 +158,8 @@ describe("Can handle user event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleUserEvent: async (_, res) => {
res.success("a", "json");
handleUserEvent: async (_, response) => {
response.success("a", "json");
}
});
const process = dispatcher.processRequest(req, res);
Expand All @@ -180,12 +180,12 @@ describe("Can handle user event", function() {
buildRequest(req, "hub", "conn1");

const dispatcher = new CloudEventsDispatcher("hub", ["*"], {
handleUserEvent: async (_, res) => {
res.setState("key1", "val1");
res.setState("key2", "val2");
res.setState("key1", "val3");
res.setState("key3", "");
res.success();
handleUserEvent: async (_, response) => {
response.setState("key1", "val1");
response.setState("key2", "val2");
response.setState("key1", "val3");
response.setState("key3", "");
response.success();
}
});
const process = dispatcher.processRequest(req, res);
Expand Down

0 comments on commit 0456250

Please sign in to comment.