From 0df82fbe56cc3db730cf22529a9141ab6e7d8292 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Thu, 9 Feb 2023 18:05:20 +1300 Subject: [PATCH 1/7] chore: use a more complete list of entry and project files --- knip.jsonc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/knip.jsonc b/knip.jsonc index a16c8fb9..a3de846e 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -1,5 +1,5 @@ { "$schema": "https://unpkg.com/knip@next/schema.json", - "entry": "src/index.ts!", - "project": "src/**/*.ts!" + "entry": ["src/index.ts!", "src/**/*.test.ts"], + "project": ["src/**/!(*.test).ts!", "src/**/*.ts"] } From 0f824f41e1b1a17d17ba372ec58dfacdfe99fcd3 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Mon, 13 Feb 2023 15:34:28 +1300 Subject: [PATCH 2/7] chore: include all index files as entry points workaround for knip/issues/62 --- knip.jsonc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/knip.jsonc b/knip.jsonc index fc121fa9..b4c724c0 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -1,7 +1,5 @@ { "$schema": "https://unpkg.com/knip@next/schema.json", - "entry": ["src/index.ts!", "src/**/*.test.ts"], - "project": ["src/**/!(*.test).ts!", "src/**/*.ts"], - // TODO: /~https://github.com/JoshuaKGoldberg/ts-api-utils/issues/45 - "ignore": ["src/nodes/typeGuards/!(*.test).ts"] + "entry": ["src/**/index.ts!", "src/**/*.test.ts"], + "project": ["src/**/!(*.test).ts!", "src/**/*.ts"] } From 375b3211ee23019f2c477cd06ddd7e4ffb3387a2 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Mon, 13 Feb 2023 15:35:23 +1300 Subject: [PATCH 3/7] chore: ignore test dir as well as test files when not in production mode --- knip.jsonc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/knip.jsonc b/knip.jsonc index b4c724c0..d6863769 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -1,5 +1,9 @@ { "$schema": "https://unpkg.com/knip@next/schema.json", "entry": ["src/**/index.ts!", "src/**/*.test.ts"], - "project": ["src/**/!(*.test).ts!", "src/**/*.ts"] + "project": [ + "src/!(test)/**/!(*.test).ts!", + "src/!(*.test).ts!", + "src/**/*.ts" + ] } From 6d13f48f20f3ad87e65e5a3d73ed30d0dbb05e04 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Mon, 13 Feb 2023 15:40:17 +1300 Subject: [PATCH 4/7] ci: run knip in both production and development mode --- .github/workflows/knip.yml | 1 + package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml index a0d0f409..34523ab5 100644 --- a/.github/workflows/knip.yml +++ b/.github/workflows/knip.yml @@ -13,3 +13,4 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/prepare - run: pnpm lint:knip + - run: pnpm lint:knip:production diff --git a/package.json b/package.json index c01a90dc..fc15928d 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "format:write": "pnpm format --write", "lint": "eslint . --max-warnings 0 --report-unused-disable-directives", "lint:knip": "knip", + "lint:knip:production": "knip --production", "lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line", "lint:package": "npmPkgJsonLint .", "lint:packages": "pnpm-deduplicate --list", From 33373f7416891eabaab7c4331f7e57da9b25e7c5 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Tue, 14 Feb 2023 16:20:24 +1300 Subject: [PATCH 5/7] chore: fix knip config globs by using different config files per mode --- knip.jsonc | 8 ++------ knip.production.jsonc | 5 +++++ package.json | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 knip.production.jsonc diff --git a/knip.jsonc b/knip.jsonc index d6863769..e50a0608 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -1,9 +1,5 @@ { "$schema": "https://unpkg.com/knip@next/schema.json", - "entry": ["src/**/index.ts!", "src/**/*.test.ts"], - "project": [ - "src/!(test)/**/!(*.test).ts!", - "src/!(*.test).ts!", - "src/**/*.ts" - ] + "entry": ["src/**/index.ts", "src/**/*.test.ts"], + "project": ["src/**/*.ts"] } diff --git a/knip.production.jsonc b/knip.production.jsonc new file mode 100644 index 00000000..d17323c0 --- /dev/null +++ b/knip.production.jsonc @@ -0,0 +1,5 @@ +{ + "$schema": "https://unpkg.com/knip@next/schema.json", + "entry": ["src/**/index.ts!"], + "project": ["src/**/*.ts!", "!src/test/**/*.ts!", "!src/**/*.test.ts!"] +} diff --git a/package.json b/package.json index edbdcf13..be72ef0a 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,8 @@ "format": "prettier \"**/*\" --ignore-unknown", "format:write": "pnpm format --write", "lint": "eslint . --max-warnings 0 --report-unused-disable-directives", - "lint:knip": "knip", - "lint:knip:production": "knip --production", + "lint:knip": "knip --config knip.jsonc", + "lint:knip:production": "knip -c knip.production.jsonc --production", "lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line", "lint:package": "npmPkgJsonLint .", "lint:packages": "pnpm-deduplicate --list", From 555e4f0f2c169dd267c701411decc8ac3c125d61 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Tue, 14 Feb 2023 16:39:53 +1300 Subject: [PATCH 6/7] ci: split knip into 2 workflows --- .github/workflows/knip-production.yml | 15 +++++++++++++++ .github/workflows/knip.yml | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/knip-production.yml diff --git a/.github/workflows/knip-production.yml b/.github/workflows/knip-production.yml new file mode 100644 index 00000000..ff2f3734 --- /dev/null +++ b/.github/workflows/knip-production.yml @@ -0,0 +1,15 @@ +name: Lint Knip (Production) + +on: + push: + branches: + - main + pull_request: + +jobs: + knip: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: pnpm lint:knip:production diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml index 34523ab5..ced6afa7 100644 --- a/.github/workflows/knip.yml +++ b/.github/workflows/knip.yml @@ -1,4 +1,4 @@ -name: Lint Knip +name: Lint Knip (Development) on: push: @@ -13,4 +13,3 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/prepare - run: pnpm lint:knip - - run: pnpm lint:knip:production From 418eae93b7362d71f488e5de1e087c73f3b2ce59 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Sat, 18 Feb 2023 01:02:59 +1300 Subject: [PATCH 7/7] chore: use --config over -c --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d1b28547..2a0ebcbd 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "format:write": "pnpm format --write", "lint": "eslint . --max-warnings 0 --report-unused-disable-directives", "lint:knip": "knip --config knip.jsonc", - "lint:knip:production": "knip -c knip.production.jsonc --production", + "lint:knip:production": "knip --config knip.production.jsonc --production", "lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line", "lint:package": "npmPkgJsonLint .", "lint:packages": "pnpm-deduplicate --list",