From d80b2a8dd900fcf4ae5f42ce395c7f6f9b3940df Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 2 Jan 2024 16:13:08 +0000 Subject: [PATCH 01/11] template: @types/supertest ^6.0.0 --- template/express-rest-api/package.json | 2 +- template/koa-rest-api/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/template/express-rest-api/package.json b/template/express-rest-api/package.json index 3e747fe1d..efbdbfeda 100644 --- a/template/express-rest-api/package.json +++ b/template/express-rest-api/package.json @@ -19,7 +19,7 @@ "devDependencies": { "@types/express": "^4.17.13", "@types/node": "^20.9.0", - "@types/supertest": "^2.0.11", + "@types/supertest": "^6.0.0", "pino-pretty": "^10.0.0", "skuba": "*", "supertest": "^6.1.6" diff --git a/template/koa-rest-api/package.json b/template/koa-rest-api/package.json index 0735e516a..1db21fc77 100644 --- a/template/koa-rest-api/package.json +++ b/template/koa-rest-api/package.json @@ -37,7 +37,7 @@ "@types/koa-bodyparser": "^5.0.2", "@types/koa__router": "^12.0.0", "@types/node": "^20.9.0", - "@types/supertest": "^2.0.11", + "@types/supertest": "^6.0.0", "chance": "^1.1.8", "pino-pretty": "^10.0.0", "skuba": "*", From fbc6326a2d7245ee6cd9ea3c4b12c7031d8ec712 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 09:58:39 +1100 Subject: [PATCH 02/11] Try to bump eslint-config-skuba --- .changeset/five-baboons-smell.md | 16 ++++++++++++++++ package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 .changeset/five-baboons-smell.md diff --git a/.changeset/five-baboons-smell.md b/.changeset/five-baboons-smell.md new file mode 100644 index 000000000..4c36334aa --- /dev/null +++ b/.changeset/five-baboons-smell.md @@ -0,0 +1,16 @@ +--- +'skuba': patch +--- + +lint: Disable `Promise` return checks in tests + +This works around the following incompatibility between Koa and the built-in `http.RequestListener` type: + +```typescript +const app = new Koa(); + +const agent = supertest.agent(app.callback()); +// ~~~~~~~~~~~~~~ +// Promise returned in function argument where a void return was expected. +// @typescript-eslint/no-misused-promises +``` diff --git a/package.json b/package.json index b0c207e5c..4671d840c 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "enquirer": "^2.3.6", "esbuild": "~0.19.0", "eslint": "^8.11.0", - "eslint-config-skuba": "3.0.4", + "eslint-config-skuba": "3.1.0", "execa": "^5.0.0", "fdir": "^6.0.0", "fs-extra": "^11.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ccbc19941..0e64879a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,8 +54,8 @@ dependencies: specifier: ^8.11.0 version: 8.56.0 eslint-config-skuba: - specifier: 3.0.4 - version: 3.0.4(eslint@8.56.0)(jest@29.7.0)(typescript@5.3.3) + specifier: 3.1.0 + version: 3.1.0(eslint@8.56.0)(jest@29.7.0)(typescript@5.3.3) execa: specifier: ^5.0.0 version: 5.1.1 @@ -3893,8 +3893,8 @@ packages: - supports-color dev: false - /eslint-config-skuba@3.0.4(eslint@8.56.0)(jest@29.7.0)(typescript@5.3.3): - resolution: {integrity: sha512-V+8u/XT/40pBtB/2pqMPV37tKdZCXsod4wGPmDpOPgb0svXR7dufLjWVOnmpbxP+7SpwAZOBf5r7Mt2K4uS+Vw==} + /eslint-config-skuba@3.1.0(eslint@8.56.0)(jest@29.7.0)(typescript@5.3.3): + resolution: {integrity: sha512-lBn7sCe73BJQVy1f0sNjsDkOySrVMR2sbZ46MQ7x2nKokL4kESEwPxKlIylX+Qzw+P/56kCwaauDL+atBuukOg==} peerDependencies: eslint: '>= 7.2' typescript: '>= 3.9' From 3c3391c3535fa688bb6b0577ea8784d2d7898af9 Mon Sep 17 00:00:00 2001 From: skuba <34733141+seek-oss-ci@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:00:34 +0000 Subject: [PATCH 03/11] Run `skuba format` --- src/wrapper/testing/httpServerRequestListener.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wrapper/testing/httpServerRequestListener.ts b/src/wrapper/testing/httpServerRequestListener.ts index eee075d7b..5ae664311 100644 --- a/src/wrapper/testing/httpServerRequestListener.ts +++ b/src/wrapper/testing/httpServerRequestListener.ts @@ -9,7 +9,7 @@ const app = new Koa().use((ctx) => { }); // FIXME: https://github.com/koajs/koa/issues/1755 -// eslint-disable-next-line @typescript-eslint/no-misused-promises + const httpServer = http.createServer(app.callback()); Object.assign(httpServer, { From e0bc164ab5f0828e96520ba463fc131d9175f66b Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 10:12:08 +1100 Subject: [PATCH 04/11] Try to fix `pnpm link` --- scripts/test-template.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/test-template.sh b/scripts/test-template.sh index 09a09254d..f024f6dd5 100755 --- a/scripts/test-template.sh +++ b/scripts/test-template.sh @@ -50,6 +50,9 @@ mv "${directory}" "../${directory}" cd "../${directory}" || exit 1 +echo '--- pnpm link --global skuba' +pnpm link --global skuba + echo "--- skuba version ${template}" skuba version skuba -v From 317feba50642a24a8f8caf0a0ad629d4c77c8147 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 12:09:52 +1100 Subject: [PATCH 05/11] Use `pnpm add` --- scripts/test-template.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/test-template.sh b/scripts/test-template.sh index f024f6dd5..34715bb50 100755 --- a/scripts/test-template.sh +++ b/scripts/test-template.sh @@ -19,9 +19,6 @@ pnpm install --frozen-lockfile echo '--- pnpm run build' pnpm run build -echo '--- pnpm link --global' -pnpm link --global - echo "--- skuba init ${template}" skuba init << EOF { @@ -50,8 +47,9 @@ mv "${directory}" "../${directory}" cd "../${directory}" || exit 1 -echo '--- pnpm link --global skuba' -pnpm link --global skuba +# @types/jest doesn't seem to get hoisted correctly when linking with pnpm. +echo '--- pnpm add ../skuba @types/jest' +pnpm add ../skuba @types/jest echo "--- skuba version ${template}" skuba version From cb8d6a4bf685a8307f6e0c1c6ed12961fde09513 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 12:14:15 +1100 Subject: [PATCH 06/11] Try something --- scripts/test-template.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/test-template.sh b/scripts/test-template.sh index 34715bb50..f578ef519 100755 --- a/scripts/test-template.sh +++ b/scripts/test-template.sh @@ -20,7 +20,7 @@ echo '--- pnpm run build' pnpm run build echo "--- skuba init ${template}" -skuba init << EOF +pnpm exec skuba init << EOF { "destinationDir": "${directory}", "templateComplete": true, @@ -52,9 +52,9 @@ echo '--- pnpm add ../skuba @types/jest' pnpm add ../skuba @types/jest echo "--- skuba version ${template}" -skuba version -skuba -v -skuba --version +pnpm exec skuba version +pnpm exec skuba -v +pnpm exec skuba --version set +e echo "--- pnpm run build ${template}" From 46909692becc4240abe658f4d044c97e138b8834 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 12:16:08 +1100 Subject: [PATCH 07/11] Again --- package.json | 3 ++- scripts/test-template.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4671d840c..54ee0a590 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ "lint": "pnpm run --silent skuba lint && pnpm run --silent lint:md", "lint:md": "remark --frail --quiet .", "release": "pnpm run --silent build && changeset publish", - "skuba": "pnpm run --silent build && node --env-file=.env lib/skuba", + "skuba": "pnpm run --silent build && pnpm run --silent skuba:exec", + "skuba:exec": "node --env-file=.env lib/skuba", "stage": "changeset version && pnpm run format", "test": "pnpm run --silent skuba test --selectProjects unit", "test:ci": "pnpm run --silent skuba test --runInBand", diff --git a/scripts/test-template.sh b/scripts/test-template.sh index f578ef519..9de3dc1a3 100755 --- a/scripts/test-template.sh +++ b/scripts/test-template.sh @@ -20,7 +20,7 @@ echo '--- pnpm run build' pnpm run build echo "--- skuba init ${template}" -pnpm exec skuba init << EOF +pnpm run skuba:exec init << EOF { "destinationDir": "${directory}", "templateComplete": true, From ae88c70f6d5857cafac9fcc667edf86bd8a609c8 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 12:22:28 +1100 Subject: [PATCH 08/11] Use `--save-dev` --- scripts/test-template.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/test-template.sh b/scripts/test-template.sh index 9de3dc1a3..a1a753403 100755 --- a/scripts/test-template.sh +++ b/scripts/test-template.sh @@ -48,8 +48,8 @@ mv "${directory}" "../${directory}" cd "../${directory}" || exit 1 # @types/jest doesn't seem to get hoisted correctly when linking with pnpm. -echo '--- pnpm add ../skuba @types/jest' -pnpm add ../skuba @types/jest +echo '--- pnpm add --save-dev ../skuba @types/jest' +pnpm add --save-dev ../skuba @types/jest echo "--- skuba version ${template}" pnpm exec skuba version From 55c547a1b38a411c7aabaf357a6b0942f377b9c6 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 12:42:18 +1100 Subject: [PATCH 09/11] Use the same `@types/jest` version --- scripts/test-template.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/test-template.sh b/scripts/test-template.sh index a1a753403..80a22b884 100755 --- a/scripts/test-template.sh +++ b/scripts/test-template.sh @@ -10,6 +10,8 @@ fi directory="tmp-${template}" +types_jest="@types/jest@$(jq --raw-output '.dependencies."@types/jest"' < package.json)" + echo '--- cleanup' rm -rf "${directory}" "../${directory}" @@ -48,8 +50,8 @@ mv "${directory}" "../${directory}" cd "../${directory}" || exit 1 # @types/jest doesn't seem to get hoisted correctly when linking with pnpm. -echo '--- pnpm add --save-dev ../skuba @types/jest' -pnpm add --save-dev ../skuba @types/jest +echo "--- pnpm add --save-dev ../skuba ${types_jest}" +pnpm add --save-dev ../skuba "${types_jest}" echo "--- skuba version ${template}" pnpm exec skuba version From 5ac2008b68d65a5cb5e5052123fc6dee0c575633 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 12:44:23 +1100 Subject: [PATCH 10/11] Link to Koa issue --- .changeset/five-baboons-smell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/five-baboons-smell.md b/.changeset/five-baboons-smell.md index 4c36334aa..1911e201b 100644 --- a/.changeset/five-baboons-smell.md +++ b/.changeset/five-baboons-smell.md @@ -4,7 +4,7 @@ lint: Disable `Promise` return checks in tests -This works around the following incompatibility between Koa and the built-in `http.RequestListener` type: +This works around an [existing incompatibility](https://github.com/koajs/koa/issues/1755) between Koa and the built-in `http.RequestListener` type: ```typescript const app = new Koa(); From 8231974644867b6c15d309cbb68bed2955d81696 Mon Sep 17 00:00:00 2001 From: Ryan Ling Date: Wed, 3 Jan 2024 12:44:33 +1100 Subject: [PATCH 11/11] Remove FIXME --- src/wrapper/testing/httpServerRequestListener.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/wrapper/testing/httpServerRequestListener.ts b/src/wrapper/testing/httpServerRequestListener.ts index 5ae664311..2b2464653 100644 --- a/src/wrapper/testing/httpServerRequestListener.ts +++ b/src/wrapper/testing/httpServerRequestListener.ts @@ -8,8 +8,6 @@ const app = new Koa().use((ctx) => { } }); -// FIXME: https://github.com/koajs/koa/issues/1755 - const httpServer = http.createServer(app.callback()); Object.assign(httpServer, {