From 9316352f6c8a3573635972adb05c76c764d25e02 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 11 Nov 2024 10:43:17 +0200 Subject: [PATCH 1/5] fix: add warning limit for eslint in gateway --- packages/gateway/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gateway/package.json b/packages/gateway/package.json index e5bddb313d..c0a733f844 100644 --- a/packages/gateway/package.json +++ b/packages/gateway/package.json @@ -17,7 +17,7 @@ "gen:schema:watch": "nodemon --quiet --on-change-only -e graphql -i src/graphql/schema.graphql -x 'yarn gen:schema'", "gen:types:watch": "nodemon --quiet --on-change-only -w src/graphql/schema.graphql -x 'yarn gen:types'", "open:cov": "yarn test && opener coverage/index.html", - "lint": "eslint -c .eslintrc.js --fix ./src" + "lint": "eslint -c .eslintrc.js --fix ./src --max-warnings=0" }, "dependencies": { "@elastic/elasticsearch": "8.13.1", From 09878a85e489f2cbac330d699f41a076a2c497eb Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 11 Nov 2024 10:44:22 +0200 Subject: [PATCH 2/5] fix: update gh action logging for knip --- .github/workflows/lint-and-test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 4afa00a76b..2c21f89068 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -170,9 +170,9 @@ jobs: OUTPUT=$(npx knip --no-exit-code --exports --reporter=./knip-reporter.js) JSON=$(echo "$OUTPUT" | grep -o '{.*}') total_issues=$(echo "$JSON" | jq '.totalIssues') - echo "Total Issues: $total_issues" + echo "Found $total_issues issue(s) on base branch." + echo "Setting $total_issues issue(s) as max limit for PR branch." echo "maxIssues=${total_issues}" >> $GITHUB_OUTPUT - echo "Max issues = $maxIssues" - name: Checkout the PR branch uses: actions/checkout@v2 @@ -198,5 +198,4 @@ jobs: export default reporter; EOF - name: Run knip on PR branch - run: | - npx knip --max-issues=${{ steps.knip_base.outputs.maxIssues }} --exports --reporter=./knip-reporter.js + run: npx knip --max-issues=${{ steps.knip_base.outputs.maxIssues }} --exports --reporter=./knip-reporter.js From 3827c4b61e35396f4e206dc696f4c8a0553663b4 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 11 Nov 2024 10:53:35 +0200 Subject: [PATCH 3/5] fix: add unused function to test knip trigger --- packages/notification/src/i18n/utils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/notification/src/i18n/utils.ts b/packages/notification/src/i18n/utils.ts index d025a75442..4dc498a2b5 100644 --- a/packages/notification/src/i18n/utils.ts +++ b/packages/notification/src/i18n/utils.ts @@ -16,3 +16,5 @@ export function getAvailableLanguages() { export function getDefaultLanguage() { return getAvailableLanguages()[0] } + +export function unusedFn() {} From 77792847809fcc3a46e1f4da1c71ab93202d17f6 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 11 Nov 2024 12:02:29 +0200 Subject: [PATCH 4/5] fix(knip): update custom counter logic to include right error types --- .github/workflows/lint-and-test.yml | 46 ++++++++++++++++------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 2c21f89068..815b286d17 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -152,17 +152,20 @@ jobs: run: | cat << 'EOF' > knip-reporter.js const reporter = function (options) { - const totalIssues = Object.values(options.issues).reduce( - (acc, issueRecords) => - acc + Object.values(issueRecords).reduce( - (acc2, issuesInFile) => acc2 + Object.keys(issuesInFile).length, - 0 - ), + const totalIssues = Object.entries(options.counters).reduce( + (acc, [key, value]) => { + if (options.report[key]) { + return acc + value + } + + return acc + }, 0 - ); - console.log(JSON.stringify({ totalIssues })); - }; - export default reporter; + ) + + console.log(JSON.stringify({ totalIssues })) + } + export default reporter EOF - name: Run knip on base branch id: knip_base @@ -185,17 +188,20 @@ jobs: run: | cat << 'EOF' > knip-reporter.js const reporter = function (options) { - const totalIssues = Object.values(options.issues).reduce( - (acc, issueRecords) => - acc + Object.values(issueRecords).reduce( - (acc2, issuesInFile) => acc2 + Object.keys(issuesInFile).length, - 0 - ), + const totalIssues = Object.entries(options.counters).reduce( + (acc, [key, value]) => { + if (options.report[key]) { + return acc + value + } + + return acc + }, 0 - ); - console.log(JSON.stringify({ totalIssues })); - }; - export default reporter; + ) + + console.log(JSON.stringify({ totalIssues })) + } + export default reporter EOF - name: Run knip on PR branch run: npx knip --max-issues=${{ steps.knip_base.outputs.maxIssues }} --exports --reporter=./knip-reporter.js From 02a96b67e276d34d6c02c24caf836833e1364e10 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 11 Nov 2024 12:30:35 +0200 Subject: [PATCH 5/5] fix: remove unused export created for testing --- packages/notification/src/i18n/utils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/notification/src/i18n/utils.ts b/packages/notification/src/i18n/utils.ts index 4dc498a2b5..d025a75442 100644 --- a/packages/notification/src/i18n/utils.ts +++ b/packages/notification/src/i18n/utils.ts @@ -16,5 +16,3 @@ export function getAvailableLanguages() { export function getDefaultLanguage() { return getAvailableLanguages()[0] } - -export function unusedFn() {}