Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eslint for wps express #17962

Merged
merged 2 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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