From 96e4264029b702cf23ea914da54295224c6a24d1 Mon Sep 17 00:00:00 2001 From: Bryan Kendall Date: Tue, 2 Jan 2024 15:53:30 -0800 Subject: [PATCH] rm @typescript-eslint/no-floating-promises --- .eslintrc.js | 3 -- test/unit/middleware/env.spec.js | 4 +- test/unit/middleware/headers.spec.js | 10 ++--- test/unit/middleware/not-found.spec.js | 4 +- test/unit/middleware/redirects.spec.js | 60 +++++++++++++++----------- test/unit/server.spec.js | 14 +++--- 6 files changed, 50 insertions(+), 45 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 85afed9..b70e7db 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -62,9 +62,6 @@ module.exports = { env: { mocha: true, }, - rules: { - "@typescript-eslint/no-floating-promises": "warn", // TODO(bkendall): remove allow to error. - }, }, ], settings: { diff --git a/test/unit/middleware/env.spec.js b/test/unit/middleware/env.spec.js index 1371d22..f25f90c 100644 --- a/test/unit/middleware/env.spec.js +++ b/test/unit/middleware/env.spec.js @@ -47,7 +47,7 @@ describe("env", () => { }), ); - request(app) + void request(app) .get("/__/env.json") .expect(200) .expect({ @@ -66,7 +66,7 @@ describe("env", () => { }), ); - request(app) + void request(app) .get("/__/env.js") .expect(200) .expect("content-type", "application/javascript; charset=utf-8") diff --git a/test/unit/middleware/headers.spec.js b/test/unit/middleware/headers.spec.js index 078be6a..3bcb008 100644 --- a/test/unit/middleware/headers.spec.js +++ b/test/unit/middleware/headers.spec.js @@ -49,7 +49,7 @@ describe("cors middleware", () => { .use(headers({ headers: defaultHeaders })) .use(okay); - request(app) + void request(app) .get("/test1") .expect(200) .expect("Content-Type", "mime/type") @@ -61,7 +61,7 @@ describe("cors middleware", () => { .use(headers({ headers: defaultHeaders })) .use(okay); - request(app) + void request(app) .get("/test3") .expect(200) .expect("Access-Control-Allow-Origin", "https://www.example.net") @@ -73,7 +73,7 @@ describe("cors middleware", () => { .use(headers({ headers: defaultHeaders })) .use(okay); - request(app) + void request(app) .get("/api/whatever/you/wish") .expect(200) .expect("Access-Control-Allow-Origin", "*") @@ -94,7 +94,7 @@ describe("cors middleware", () => { ) .use(okay); - request(app) + void request(app) .get("/something") .expect(200) .expect("custom-header", "for testing") @@ -115,7 +115,7 @@ describe("cors middleware", () => { ) .use(okay); - request(app) + void request(app) .get("/resources/281.jpg") .expect(200) .expect("custom-header", "for testing") diff --git a/test/unit/middleware/not-found.spec.js b/test/unit/middleware/not-found.spec.js index 28684b5..10ae4fc 100644 --- a/test/unit/middleware/not-found.spec.js +++ b/test/unit/middleware/not-found.spec.js @@ -54,7 +54,7 @@ describe("not found", () => { }), ); - request(app) + void request(app) .get("/anything") .expect(404) .expect("not found file") @@ -76,7 +76,7 @@ describe("not found", () => { }), ); - request(app) + void request(app) .get("/anything") .expect(404) .expect("Cache-Control", "public, max-age=3600") diff --git a/test/unit/middleware/redirects.spec.js b/test/unit/middleware/redirects.spec.js index 4d419cb..15804f8 100644 --- a/test/unit/middleware/redirects.spec.js +++ b/test/unit/middleware/redirects.spec.js @@ -36,7 +36,7 @@ describe("redirect middleware", () => { it("skips the middleware if there are no redirects configured", (done) => { const app = connect().use(redirect({ redirects: [] })); - request(app).get("/").expect(404).end(done); + void request(app).get("/").expect(404).end(done); }); it("skips middleware when there are no matching redirects", (done) => { @@ -54,7 +54,7 @@ describe("redirect middleware", () => { }), ); - request(app).get("/none").expect(404).end(done); + void request(app).get("/none").expect(404).end(done); }); it("redirects to a configured path", (done) => { @@ -72,7 +72,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source") .expect(301) .expect("location", "/redirect") @@ -94,7 +94,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source") .expect(301) .expect("location", "/redirect") @@ -116,7 +116,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source") .expect(301) .expect("location", "/redirect") @@ -138,7 +138,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source") .expect(302) .expect("location", "/redirect") @@ -160,7 +160,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source") .expect(301) .expect("location", "/redirect") @@ -182,7 +182,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/anthing") .expect(301) .expect("location", "/redirect") @@ -204,7 +204,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/old/redirect/path/there") .expect(301) .expect("location", "/new/redirect/path/there") @@ -226,7 +226,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/old/capture/group/there") .expect(301) .expect("location", "/new/capture/path/there") @@ -248,7 +248,11 @@ describe("redirect middleware", () => { }), ); - request(app).get("/äöü").expect(301).expect("location", "/aou").end(done); + void request(app) + .get("/äöü") + .expect(301) + .expect("location", "/aou") + .end(done); }); it("percent encodes the redirect location", (done) => { @@ -266,7 +270,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/aou") .expect(301) .expect("location", "/%C4%87") @@ -288,7 +292,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/foo/barbar/baz") .expect(301) .expect("location", "/bar") @@ -310,7 +314,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/foo/1/2/3/4/bar") .expect(301) .expect("location", "/1/2/3/4") @@ -333,7 +337,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/foo/bar") .expect(301) .expect("location", "/foo") @@ -355,7 +359,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/mixed/capture/types") .expect(301) .expect("location", "/mixed/capture/types") @@ -378,7 +382,11 @@ describe("redirect middleware", () => { }), ); - request(app).get("/old/").expect(301).expect("location", "/new").end(done); + void request(app) + .get("/old/") + .expect(301) + .expect("location", "/new") + .end(done); }); it("redirects a present optional segment", (done) => { @@ -396,7 +404,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/old/derp") .expect(301) .expect("location", "/new/derp") @@ -418,7 +426,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/blog/this/old/post") .expect(301) .expect("location", "/new/this/old/post") @@ -440,7 +448,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/old/redirect/path/there") .expect(302) .expect("location", "/new/redirect/path/there") @@ -462,7 +470,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source") .expect(301) .expect("Location", "http://redirectedto.com") @@ -484,7 +492,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source") .expect(301) .expect("Location", "https://redirectedto.com") @@ -506,7 +514,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source?foo=bar&baz=qux") .expect(301) .expect("Location", "/destination?foo=bar&baz=qux") @@ -528,7 +536,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source?foo=bar&baz=qux") .expect(301) .expect("Location", "/destination?hello=world&foo=bar&baz=qux") @@ -550,7 +558,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source?foo=bar&baz=qux") .expect(301) .expect("Location", "http://example.com/destination?foo=bar&baz=qux") @@ -572,7 +580,7 @@ describe("redirect middleware", () => { }), ); - request(app) + void request(app) .get("/source/wat?foo=bar&baz=qux") .expect(301) .expect("Location", "/wat/bar?foo=bar&baz=qux") diff --git a/test/unit/server.spec.js b/test/unit/server.spec.js index 0a195e5..f3d639c 100644 --- a/test/unit/server.spec.js +++ b/test/unit/server.spec.js @@ -48,7 +48,7 @@ describe.skip("server", () => { it("starts a server", (done) => { const app = server(); - request(app).get("/").end(done); + void request(app).get("/").end(done); }); it("with config", (done) => { @@ -58,7 +58,7 @@ describe.skip("server", () => { }, }); - request(app).get("/").expect("index file content").end(done); + void request(app).get("/").expect("index file content").end(done); }); it("with port", (done) => { @@ -105,7 +105,7 @@ describe.skip("server", () => { stdMocks.use(); - request(app) + void request(app) .get("/") .end(() => { stdMocks.restore(); @@ -126,7 +126,7 @@ describe.skip("server", () => { }, }); - request(app) + void request(app) .get("/__/env.json") .expect({ key: "value", @@ -144,7 +144,7 @@ describe.skip("server", () => { }, }); - request(app) + void request(app) .get("/__/env.json") .expect({ type: "object", @@ -158,7 +158,7 @@ describe.skip("server", () => { const app = server(); - return request(app).get("/nope").expect(404).expect(notFoundContent); + return void request(app).get("/nope").expect(404).expect(notFoundContent); }); it("overriden default error page", async () => { @@ -171,6 +171,6 @@ describe.skip("server", () => { }, }); - return request(app).get("/nope").expect(404).expect("error page"); + return void request(app).get("/nope").expect(404).expect("error page"); }); });