Skip to content

Commit fc77c2c

Browse files
authored
ci: introduce knip (#10384)
### Description [Knip](https://knip.dev/) is a tool that can help us to not leave unused things around the repo. This PR introduces it to check for unused dependencies in package.json. It's limited in how many packages in the repo it is checking, but we can widen out its coverage over time. ### Testing Instructions CI
1 parent d4426e4 commit fc77c2c

File tree

9 files changed

+221
-56
lines changed

9 files changed

+221
-56
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
- name: Lint
7171
# Manually set TURBO_API to an empty string to override Hetzner env
7272
run: |
73-
TURBO_API= turbo run lint --env-mode=strict
73+
TURBO_API= turbo run lint knip --env-mode=strict
7474
7575
cleanup:
7676
name: Cleanup

docs/site/app/(no-sidebar)/[...slug]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default async function Page(props: {
2020
return (
2121
<article className="prose pt-10 mx-auto mb-10 w-full min-w-0 max-w-5xl px-6 md:px-12">
2222
<h1 className="text-left">{page.data.title}</h1>
23+
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Types not inferred correctly */}
2324
<Mdx components={mdxComponents} />
2425
</article>
2526
);

docs/site/app/(no-sidebar)/blog/[...slug]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default async function Page(props: {
6161
</Link>
6262
</div>
6363

64+
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Types not inferred correctly */}
6465
<Mdx components={mdxComponents} />
6566
</article>
6667
);

docs/site/app/(sidebar)/docs/[[...slug]]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default async function Page(props: {
6161

6262
<CopyToMarkdown markdownContent={rawMarkdown} />
6363
</div>
64+
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Types not inferred correctly */}
6465
<Mdx components={mdxComponents} />
6566
</>
6667
);

docs/site/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"collect-examples-data": "node ./scripts/collect-examples-data.mjs"
2121
},
2222
"dependencies": {
23-
"@headlessui/react": "^1.7.17",
2423
"@heroicons/react": "1.0.6",
2524
"@radix-ui/react-collapsible": "^1.1.3",
2625
"@radix-ui/react-dialog": "^1.1.6",
@@ -31,7 +30,6 @@
3130
"@radix-ui/react-slot": "^1.1.2",
3231
"@radix-ui/react-tooltip": "^1.1.8",
3332
"@react-spring/web": "^9.7.3",
34-
"@turbo/gen": "workspace:*",
3533
"@vercel/speed-insights": "1.2.0",
3634
"algoliasearch": "^4.23.3",
3735
"class-variance-authority": "^0.7.1",
@@ -59,13 +57,11 @@
5957
"zod": "^3.24.2"
6058
},
6159
"devDependencies": {
62-
"@mdx-js/mdx": "^3.0.1",
6360
"@next/env": "15.3.1-canary.12",
64-
"@turbo/eslint-config": "workspace:*",
6561
"@next/eslint-plugin-next": "15.3.1-canary.12",
62+
"@turbo/eslint-config": "workspace:*",
6663
"@turbo/tsconfig": "workspace:^",
6764
"@turbo/types": "workspace:*",
68-
"@types/mdx": "^2.0.8",
6965
"@types/node": "20.11.30",
7066
"@types/react": "18.3.1",
7167
"@types/react-dom": "18.3.0",
@@ -75,7 +71,6 @@
7571
"autoprefixer": "^10.4.20",
7672
"eslint": "8.57.0",
7773
"gray-matter": "^4.0.3",
78-
"openapi-types": "^12.1.3",
7974
"postcss": "^8.4.35",
8075
"rss": "^1.2.2",
8176
"spellchecker-cli": "^6.2.0",

knip.jsonc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@5/schema-jsonc.json",
3+
"ignore": [
4+
"turborepo-tests/**",
5+
// Not working well for this package for some reason
6+
"docs/link-checker/**",
7+
// TODO: Widen coverage
8+
"packages/**"
9+
],
10+
"workspaces": {
11+
"docs/site": {
12+
"ignoreDependencies": [
13+
// TODO: We're using this but its getting reported?
14+
"copy-to-clipboard",
15+
"@next/env",
16+
"@next/eslint-plugin-next",
17+
"rss",
18+
"@radix-ui/react-dropdown-menu"
19+
]
20+
}
21+
}
22+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint:prettier": "turbo run lint:prettier",
1010
"check:toml": "taplo format --check",
1111
"docs:dev": "turbo run dev --filter=turborepo-docs",
12+
"knip": "knip --include dependencies",
1213
"turbo": "pnpm run build:turbo && node turbow.js",
1314
"turbo-prebuilt": "node turbow.js",
1415
"prepare": "husky install",
@@ -19,8 +20,10 @@
1920
},
2021
"devDependencies": {
2122
"@taplo/cli": "^0.5.2",
23+
"@types/node": "^22.15.1",
2224
"eslint": "^8.55.0",
2325
"husky": "^8.0.0",
26+
"knip": "^5.50.5",
2427
"lint-staged": "^13.1.0",
2528
"prettier": "^2.8.7",
2629
"semver": "^7.3.8",

0 commit comments

Comments
 (0)