Skip to content

Commit 0e5c087

Browse files
committed
Add knip checks
1 parent aa819be commit 0e5c087

4 files changed

Lines changed: 603 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ jobs:
3838
- run: corepack yarn
3939
- run: corepack yarn lint:js
4040

41+
knip:
42+
name: Knip
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version: 22
49+
- run: corepack yarn
50+
- run: corepack yarn knip
51+
4152
typescript:
4253
name: Lint (TypeScript)
4354
runs-on: ubuntu-latest

knip.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { KnipConfig } from 'knip'
2+
3+
// Note: `yarn check` runs knip with --fix --allow-remove-files. This is safe because
4+
// lint:ts and tests run immediately after - they'll fail if knip removes something needed.
5+
const config: KnipConfig = {
6+
entry: [
7+
'src/**/*.{ts,tsx,js,jsx}',
8+
'test/**/*.{ts,tsx,js,jsx}',
9+
'scripts/**/*.{ts,tsx,js,jsx}',
10+
'vitest.config.ts',
11+
],
12+
project: ['{src,test,scripts}/**/*.{ts,tsx,js,jsx}'],
13+
ignore: [
14+
'dist/**',
15+
'coverage/**',
16+
'static-build/**',
17+
'node_modules/**',
18+
// alphalib is a shared utility library. Exclude it so knip does not remove
19+
// files that may only be used in other repos.
20+
'src/alphalib/**',
21+
],
22+
ignoreDependencies: [
23+
// Used in src/alphalib/** which is excluded from knip
24+
'@aws-sdk/client-s3',
25+
'@aws-sdk/s3-request-presigner',
26+
'@transloadit/sev-logger',
27+
'type-fest',
28+
'zod',
29+
// Repo-specific ignores
30+
'@types/minimist',
31+
'minimatch',
32+
'tsx',
33+
],
34+
rules: {
35+
duplicates: 'warn',
36+
},
37+
}
38+
39+
export default config

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,21 @@
3232
"p-queue": "^9.0.1",
3333
"recursive-readdir": "^2.2.3",
3434
"tus-js-client": "^4.3.1",
35+
"typanion": "^3.14.0",
3536
"type-fest": "^4.41.0",
3637
"zod": "3.25.76"
3738
},
3839
"devDependencies": {
3940
"@biomejs/biome": "^2.2.4",
4041
"@types/debug": "^4.1.12",
42+
"@types/node": "^24.10.3",
4143
"@types/recursive-readdir": "^2.2.4",
4244
"@types/temp": "^0.9.4",
4345
"@vitest/coverage-v8": "^3.2.4",
4446
"badge-maker": "^5.0.2",
4547
"execa": "9.6.0",
4648
"image-size": "^2.0.2",
49+
"knip": "^5.73.3",
4750
"minimatch": "^10.1.1",
4851
"nock": "^14.0.10",
4952
"npm-run-all": "^4.1.5",
@@ -62,13 +65,16 @@
6265
"src": "./src"
6366
},
6467
"scripts": {
65-
"check": "yarn lint:ts && yarn fix && yarn test:unit",
68+
"check": "yarn knip --fix --allow-remove-files --no-config-hints && yarn lint:ts && yarn fix && yarn test:unit",
6669
"fix:js": "biome check --write .",
6770
"lint:ts": "tsc --build",
6871
"fix:js:unsafe": "biome check --write . --unsafe",
6972
"lint:js": "biome check .",
7073
"lint": "npm-run-all --parallel 'lint:js'",
7174
"fix": "npm-run-all --serial 'fix:js'",
75+
"lint:deps": "knip --dependencies --no-progress",
76+
"fix:deps": "knip --dependencies --no-progress --fix",
77+
"knip": "knip --no-config-hints --no-progress",
7278
"prepack": "rm -f tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && tsc --build tsconfig.build.json",
7379
"test:unit": "vitest run --coverage ./test/unit",
7480
"test:e2e": "vitest run ./test/e2e",

0 commit comments

Comments
 (0)