From 39579715237547ad0cc3d64000c1c6c730c40b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 14:57:52 +0300 Subject: [PATCH 1/6] [collector] Stricter tsconfig --- packages/collector/tsconfig.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/collector/tsconfig.json b/packages/collector/tsconfig.json index 371325d13..803f6eaa4 100644 --- a/packages/collector/tsconfig.json +++ b/packages/collector/tsconfig.json @@ -2,8 +2,14 @@ "compilerOptions": { "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, "noImplicitReturns": true, + "noPropertyAccessFromIndexSignature": true, "noUnusedLocals": true, "noUnusedParameters": true, "strict": true From 0da6fce4709c3d215a31ca1ac4673a1764c15590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 15:02:28 +0300 Subject: [PATCH 2/6] [collector] Fixed confusing optional properties --- packages/collector/src/getProjectIssues.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/collector/src/getProjectIssues.ts b/packages/collector/src/getProjectIssues.ts index 581e3da14..668df4272 100644 --- a/packages/collector/src/getProjectIssues.ts +++ b/packages/collector/src/getProjectIssues.ts @@ -22,7 +22,7 @@ export async function getProjectIssues( }); return issues.data.map((issue) => ({ description: issue.body ?? "", - link: publicRepo ? issue.html_url : undefined, + ...(publicRepo && { link: issue.html_url }), number: issue.number, title: issue.title, })); From c4ea58d09dc209cb36c1d32fcb247c026798e74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 15:03:55 +0300 Subject: [PATCH 3/6] [collector] Using index signature to access index properties --- packages/collector/__tests__/getProjectIssues.test.ts | 10 +++++++--- packages/collector/__tests__/setup.ts | 2 +- packages/collector/src/octokit.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/collector/__tests__/getProjectIssues.test.ts b/packages/collector/__tests__/getProjectIssues.test.ts index ec58fad28..a0076161f 100644 --- a/packages/collector/__tests__/getProjectIssues.test.ts +++ b/packages/collector/__tests__/getProjectIssues.test.ts @@ -7,7 +7,9 @@ describe("Working issue listing", () => { beforeEach(() => { nock("https://api.github.com") .get("/repos/OWNER/REPO/issues") - .query((actualQueryObject) => actualQueryObject.labels === "help-wanted") + .query( + (actualQueryObject) => actualQueryObject["labels"] === "help-wanted", + ) .reply(200, [ { body: "BODY_C", @@ -18,7 +20,9 @@ describe("Working issue listing", () => { ]); nock("https://api.github.com") .get("/repos/OWNER/REPO/issues") - .query((actualQueryObject) => actualQueryObject.labels === "help wanted") + .query( + (actualQueryObject) => actualQueryObject["labels"] === "help wanted", + ) .reply(200, [ { body: "BODY_I", @@ -99,7 +103,7 @@ test("getProjectIssues auto-populates body", async () => { nock("https://api.github.com") .get("/repos/OWNER/REPO/issues") - .query((actualQueryObject) => actualQueryObject.labels === "help-wanted") + .query((actualQueryObject) => actualQueryObject["labels"] === "help-wanted") .reply(200, [ { html_url: "https://example.test", number: 1, title: "CORRECT" }, ]); diff --git a/packages/collector/__tests__/setup.ts b/packages/collector/__tests__/setup.ts index 7af8df483..028fc8219 100644 --- a/packages/collector/__tests__/setup.ts +++ b/packages/collector/__tests__/setup.ts @@ -10,7 +10,7 @@ jest.mock("../src/octokit", () => { const OctokitWithRest = Octokit.plugin(restEndpointMethods); return { octokit: new OctokitWithRest({ - auth: process.env.PAT, + auth: process.env["PAT"], request: { fetch: nodeFetch, }, diff --git a/packages/collector/src/octokit.ts b/packages/collector/src/octokit.ts index cab269f88..d1601a788 100644 --- a/packages/collector/src/octokit.ts +++ b/packages/collector/src/octokit.ts @@ -3,4 +3,4 @@ import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods"; // eslint-disable-next-line @typescript-eslint/naming-convention -- Classes should be PascalCase const OctokitWithRest = Octokit.plugin(restEndpointMethods); -export const octokit = new OctokitWithRest({ auth: process.env.PAT }); +export const octokit = new OctokitWithRest({ auth: process.env["PAT"] }); From 173e7a252be6e4e3286a2ddec6b6c59938223b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 15:04:57 +0300 Subject: [PATCH 4/6] [collector] Fixed eslint FP on js files --- packages/collector/eslint.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/collector/eslint.config.js b/packages/collector/eslint.config.js index 06b5c693f..af61d636a 100644 --- a/packages/collector/eslint.config.js +++ b/packages/collector/eslint.config.js @@ -207,6 +207,7 @@ export default tseslint.config( files: ["**/*.js"], rules: { "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", }, }, ); From 7c365f9e3a83e258e6816263200c85a16c11c721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 15:08:45 +0300 Subject: [PATCH 5/6] [frontend] Stricter tsconfig --- packages/frontend/tsconfig.json | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/frontend/tsconfig.json b/packages/frontend/tsconfig.json index cf3f657df..7aad91d9d 100644 --- a/packages/frontend/tsconfig.json +++ b/packages/frontend/tsconfig.json @@ -1,17 +1,23 @@ { "compilerOptions": { - "module": "es2020", - "moduleResolution": "node", "allowSyntheticDefaultImports": true, "esModuleInterop": true, - "target": "es5", - "jsx": "react-jsx", "forceConsistentCasingInFileNames": true, + "jsx": "react-jsx", + "module": "es2020", + "moduleResolution": "node", + "sourceMap": true, + "target": "es5", + + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, "noImplicitReturns": true, + "noPropertyAccessFromIndexSignature": true, "noUnusedLocals": true, "noUnusedParameters": true, - "sourceMap": true, "strict": true } } From e403b3ba2a9741aadd5731a60cc0fa30256f17c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 15:40:09 +0300 Subject: [PATCH 6/6] [frontend] Fixed confusing optional properties --- packages/frontend/__tests__/components/IssuesList.test.tsx | 5 +++-- packages/frontend/src/components/Issue.tsx | 2 +- packages/frontend/src/components/Project.tsx | 2 +- packages/frontend/src/pages/IssueDetail.tsx | 4 ++-- packages/frontend/src/utils/getAllIssues.ts | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/frontend/__tests__/components/IssuesList.test.tsx b/packages/frontend/__tests__/components/IssuesList.test.tsx index bf1f074f0..9056a1693 100644 --- a/packages/frontend/__tests__/components/IssuesList.test.tsx +++ b/packages/frontend/__tests__/components/IssuesList.test.tsx @@ -20,8 +20,9 @@ describe("IssuesList component", () => { ({ - ...issue, - link: undefined, + description: issue.description, + number: issue.number, + title: issue.title, }))} project={project} /> diff --git a/packages/frontend/src/components/Issue.tsx b/packages/frontend/src/components/Issue.tsx index e439458ad..a9509dd4f 100644 --- a/packages/frontend/src/components/Issue.tsx +++ b/packages/frontend/src/components/Issue.tsx @@ -19,7 +19,7 @@ export const Issue = ({ subtitle={issue.project.name} subtitleDescription={issue.project["short-description"]} subtitleLink={getProjectLink(issue.project)} - tags={!hideTags ? issue.project.tags : []} + tags={!hideTags ? issue.project.tags ?? [] : []} title={issue.title} /> ); diff --git a/packages/frontend/src/components/Project.tsx b/packages/frontend/src/components/Project.tsx index 62c6279b4..8293ce897 100644 --- a/packages/frontend/src/components/Project.tsx +++ b/packages/frontend/src/components/Project.tsx @@ -13,7 +13,7 @@ export const Project = ({ ); diff --git a/packages/frontend/src/pages/IssueDetail.tsx b/packages/frontend/src/pages/IssueDetail.tsx index 319819fec..d401ed4b0 100644 --- a/packages/frontend/src/pages/IssueDetail.tsx +++ b/packages/frontend/src/pages/IssueDetail.tsx @@ -47,8 +47,8 @@ export const IssueDetail = ({ ); const projectIssues = getIssuesWithProjectInfo(data, { omitIssueNumber: issue?.number, - owner: projectOwner, - repo: projectRepo, + ...(projectOwner !== undefined && { owner: projectOwner }), + ...(projectRepo !== undefined && { repo: projectRepo }), }); if (!issue) { diff --git a/packages/frontend/src/utils/getAllIssues.ts b/packages/frontend/src/utils/getAllIssues.ts index 2fe0bee37..79c11280f 100644 --- a/packages/frontend/src/utils/getAllIssues.ts +++ b/packages/frontend/src/utils/getAllIssues.ts @@ -8,7 +8,7 @@ export interface ProjectIssueWithProjectInfo extends ProjectIssue { } interface Query extends Partial { - omitIssueNumber?: number; + omitIssueNumber: number | undefined; } export const getIssuesWithProjectInfo = (