diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml new file mode 100644 index 000000000..b65d7b0a7 --- /dev/null +++ b/.github/workflows/knip.yml @@ -0,0 +1,33 @@ +name: Knip + +on: + pull_request_target: + +permissions: + checks: write + issues: write + pull-requests: write + +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 diff --git a/knip.json b/knip.json deleted file mode 100644 index 9d5789ccc..000000000 --- a/knip.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "entry": ["src/index.ts"], - "project": ["**/*.ts"] -} diff --git a/knip.ts b/knip.ts new file mode 100644 index 000000000..4894f6ad5 --- /dev/null +++ b/knip.ts @@ -0,0 +1,11 @@ +import type { KnipConfig } from "knip"; + +const config: KnipConfig = { + entry: ["src/index.ts"], + project: ["src/**/*.ts"], + ignore: ["src/types/config.ts"], + ignoreExportsUsedInFile: true, + ignoreDependencies: [], +}; + +export default config; diff --git a/package.json b/package.json index 2830f3051..9e0a62661 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,8 @@ "build:serverless": "ncc build src/index.ts -o ./", "build": "tsc", "clean": "rimraf ./dist ./node_modules", + "knip": "knip", + "knip-ci": "knip --no-exit-code --reporter json", "preformat": "yarn lint:prettier", "format": "yarn lint:eslint", "lint": "yarn lint:prettier:check && yarn lint:eslint", @@ -74,16 +76,16 @@ "@types/libsodium-wrappers": "^0.7.10", "@types/lodash": "^4.14.197", "@types/markdown-it": "^13.0.4", - "@types/node": "^14.18.37", + "@types/node": "^18.0.0", "@types/source-map-support": "^0.5.6", "eslint": "^8.43.0", "jest": "^29.6.2", - "knip": "^2.33.4", + "knip": "^3.7.1", "octokit": "^3.1.2", "rimraf": "3.0.2", "source-map-support": "^0.5.21", "ts-jest": "^29.1.1", - "typescript": "^4.9.5" + "typescript": "^5.0.4" }, "engines": { "node": ">=18" diff --git a/tsconfig.json b/tsconfig.json index b9259e753..7da22171c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -62,6 +62,6 @@ "sourceMap": true }, "include": ["src/"], - "exclude": ["src/coverage/"], + "exclude": ["src/coverage/", "knip.ts"], "compileOnSave": false }