From 04562504507f5476f1865996091fa35526be1ca8 Mon Sep 17 00:00:00 2001 From: "Liangying.Wei" Date: Sat, 2 Oct 2021 00:27:32 +0800 Subject: [PATCH] Fix eslint for wps express (#17962) * Fix eslint for wps express * fix format failure --- .../web-pubsub-express/package.json | 2 +- .../web-pubsub-express/src/utils.ts | 2 +- .../web-pubsub-express/test/connect.spec.ts | 36 +++++++++---------- .../web-pubsub-express/test/user.spec.ts | 32 ++++++++--------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sdk/web-pubsub/web-pubsub-express/package.json b/sdk/web-pubsub/web-pubsub-express/package.json index 722c92e67772..9d34c677b8f9 100644 --- a/sdk/web-pubsub/web-pubsub-express/package.json +++ b/sdk/web-pubsub/web-pubsub-express/package.json @@ -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", diff --git a/sdk/web-pubsub/web-pubsub-express/src/utils.ts b/sdk/web-pubsub/web-pubsub-express/src/utils.ts index 31dada4b4225..d16d29469176 100644 --- a/sdk/web-pubsub/web-pubsub-express/src/utils.ts +++ b/sdk/web-pubsub/web-pubsub-express/src/utils.ts @@ -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); } diff --git a/sdk/web-pubsub/web-pubsub-express/test/connect.spec.ts b/sdk/web-pubsub/web-pubsub-express/test/connect.spec.ts index 714c39babd42..3f4152aad1af 100644 --- a/sdk/web-pubsub/web-pubsub-express/test/connect.spec.ts +++ b/sdk/web-pubsub/web-pubsub-express/test/connect.spec.ts @@ -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); @@ -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); @@ -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); @@ -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); @@ -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(); } }); @@ -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(); } }); diff --git a/sdk/web-pubsub/web-pubsub-express/test/user.spec.ts b/sdk/web-pubsub/web-pubsub-express/test/user.spec.ts index e4887dd573b7..80d78a552993 100644 --- a/sdk/web-pubsub/web-pubsub-express/test/user.spec.ts +++ b/sdk/web-pubsub/web-pubsub-express/test/user.spec.ts @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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);