From 83b6cb68ce08cd279b315718586ad8f136e065ba Mon Sep 17 00:00:00 2001 From: Korrrba Date: Mon, 19 Feb 2024 22:32:10 +0100 Subject: [PATCH] feat: add knip CI configuration Resolves: https://github.com/ubiquity/ts-template/issues/12 --- .github/workflows/knip.yml | 30 ++++++++++++++++++++++++++++++ knip.ts | 11 +++++++++++ package.json | 2 ++ 3 files changed, 43 insertions(+) create mode 100644 .github/workflows/knip.yml create mode 100644 knip.ts diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml new file mode 100644 index 0000000..86c3afb --- /dev/null +++ b/.github/workflows/knip.yml @@ -0,0 +1,30 @@ +name: Knip + +on: + pull_request: + +permissions: write-all + +jobs: + run-knip: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 20.10.x + + - name: Install toolchain + run: yarn install + + - name: Report knip results to pull request + uses: Codex-/knip-reporter@v2 + with: + verbose: true + comment_id: ${{ github.workflow }}-reporter + command_script_name: knip-ci + annotations: true + ignore_results: false \ No newline at end of file diff --git a/knip.ts b/knip.ts new file mode 100644 index 0000000..57b5e39 --- /dev/null +++ b/knip.ts @@ -0,0 +1,11 @@ +import type { KnipConfig } from "knip"; + +const config: KnipConfig = { + entry: ["build/index.ts"], + project: ["src/**/*.ts"], + ignore: ["src/types/config.ts"], + ignoreExportsUsedInFile: true, + ignoreDependencies: [], +}; + +export default config; \ No newline at end of file diff --git a/package.json b/package.json index 7797e06..73e995c 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,8 @@ "format:lint": "eslint --fix .", "format:prettier": "prettier --write .", "format:cspell": "cspell **/*", + "knip": "knip", + "knip-ci": "knip --no-exit-code --reporter json", "prepare": "husky install" }, "keywords": [