Skip to content

refactor: remove unused code/deps, configure knip - #7117

Merged
serhalp merged 15 commits into
mainfrom
serhalp/refactor/remove-unused-and-configure-knip
Aug 6, 2026
Merged

refactor: remove unused code/deps, configure knip#7117
serhalp merged 15 commits into
mainfrom
serhalp/refactor/remove-unused-and-configure-knip

Conversation

@serhalp

@serhalp serhalp commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds https://knip.dev/, a fantastic tool that reliably flags unused code and dependencies, and configures it to run in CI.

It also removes what it flagged as unused.

Note that I already did a manual pass last year: #6097.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 97731d29-b055-45e9-81ff-661e7fd2d38f

📥 Commits

Reviewing files that changed from the base of the PR and between 89ded43 and 3bcc73e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • packages/config/package.json
  • packages/js-client/package.json
  • packages/js-client/tsconfig.json
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • netlify/blueprints (manual)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/js-client/tsconfig.json
  • packages/js-client/package.json
  • packages/config/package.json

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added automated unused-code checks for pull requests.
    • Added guidance for identifying and removing unused files, dependencies, and exports.
    • Updated supported bundle formats.
  • Bug Fixes

    • Improved test server startup and setup path handling.
    • Simplified function configuration validation.
  • Chores

    • Streamlined package configuration and CI installation.
    • Removed outdated helpers, exports, and unused development dependencies.
    • Refreshed project metadata and skill configuration.

Walkthrough

This PR integrates Knip for monorepo unused-code detection. It adds configuration, workspace rules, a root script, pull request CI, and a skill guide. It removes unused exports, types, logging helpers, parser logic, and package development dependencies. It removes JavaScript bundle format support and updates related schemas and fixtures. It also updates build-info test-server wiring and the conventional-commit workflow.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • netlify/build#7132: Updates edge-bundler function-selection behavior while sharing changes to manifest and bundle-format handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the main changes but omits the required issue reference and contribution, test, documentation, and status-check confirmations. Add the issue reference and complete the required checklist, including contribution guidelines, tests, documentation, and status checks.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: removing unused code and dependencies and configuring Knip.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch serhalp/refactor/remove-unused-and-configure-knip

Comment @coderabbitai help to get the list of available commands.

"@vitest/ui": "^3.0.0",
"execa": "^8.0.0",
"memfs": "^4.0.0",
"typescript": "^5.0.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typescript was assumed to be hoisted in the root but was declared instead as a dev dep in many (but not all) individual packages. I centralized it as a dev dep in the root.

"execa": "^8.0.0",
"memfs": "^4.0.0",
"typescript": "^5.0.0",
"ts-node": "^10.9.2",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts-node was missing from this package; it just happened to work due to hoisting

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

⚠️ Dependency Count

This PR adds 20 new dependencies (1552 → 1572), which exceeds the threshold of 10.

📊 Dependency Size Changes

Warning

This PR adds 19.9 MB of new dependencies, which exceeds the threshold of 100 kB.

📦 Package 📏 Size
@napi-rs/wasm-runtime@1.1.6 6.3 MB
@oxc-parser/binding-linux-x64-gnu@0.137.0 2.4 MB
@oxc-resolver/binding-linux-x64-gnu@11.21.3 2.4 MB
@emnapi/core@1.11.1 2 MB
@emnapi/core@1.11.0 2 MB
knip@6.21.0 1.7 MB
oxc-parser@0.137.0 1.4 MB
@tybys/wasm-util@0.10.3 825.1 kB
@emnapi/runtime@1.11.1 433.5 kB
@emnapi/runtime@1.11.0 433.5 kB
@emnapi/wasi-threads@1.2.2 225.1 kB
unbash@4.0.1 180.9 kB
import-meta-resolve@4.2.0 -79.2 kB
@commitlint/rules@19.8.1 -70.6 kB
oxc-resolver@11.21.3 60.2 kB
lodash.mergewith@4.6.2 -54.2 kB
jiti@2.6.1 → jiti@2.7.0 50.5 kB
@oxc-project/types@0.137.0 44.5 kB
@commitlint/load@19.8.1 -36.3 kB
@commitlint/cli@19.8.1 -32.5 kB
conventional-commits-parser@5.0.0 -29.9 kB
tar@7.5.16 → tar@7.5.19 23.2 kB
tinyexec@1.2.4 -22.9 kB
formatly@0.3.0 21.6 kB
split2@4.2.0 -17.4 kB
@commitlint/resolve-extends@19.8.1 -17 kB
@commitlint/lint@19.8.1 -14 kB
cosmiconfig-typescript-loader@6.3.0 -13.9 kB
@commitlint/read@19.8.1 -13.2 kB
ini@4.1.1 -12.7 kB
dargs@8.1.0 -12.3 kB
@commitlint/config-validator@19.8.1 -12.1 kB
@commitlint/ensure@19.8.1 -12 kB
@commitlint/format@19.8.1 -10.5 kB
strip-json-comments@5.0.3 8.2 kB
global-directory@4.0.1 -8.1 kB
git-raw-commits@4.0.0 -7.9 kB
fd-package-json@2.0.0 7.7 kB
@commitlint/is-ignored@19.8.1 -6.9 kB
text-extensions@2.4.0 -6.3 kB
@commitlint/parse@19.8.1 -4.6 kB
@commitlint/execute-rule@19.8.1 -3.9 kB
@commitlint/top-level@19.8.1 -3.7 kB
is-text-path@2.0.0 -2.9 kB
@types/is-ci@3.0.4 -2.9 kB
@commitlint/to-lines@19.8.1 -2.7 kB
@commitlint/message@19.8.1 -2.7 kB
js-yaml@3.14.2 → js-yaml@3.15.0 1.2 kB
p-map@7.0.4 → p-map@7.0.5 490 B
nock@14.0.15 → nock@14.0.16 393 B
@typescript-eslint/types@8.62.0 → @typescript-eslint/types@8.62.1 0 B
@typescript-eslint/visitor-keys@8.62.0 → @typescript-eslint/visitor-keys@8.62.1 0 B
@typescript-eslint/project-service@8.62.0 → @typescript-eslint/project-service@8.62.1 0 B
@typescript-eslint/tsconfig-utils@8.62.0 → @typescript-eslint/tsconfig-utils@8.62.1 0 B
@typescript-eslint/typescript-estree@8.62.0 → @typescript-eslint/typescript-estree@8.62.1 0 B
lodash.isplainobject@4.0.6 Unknown
lodash.kebabcase@4.1.1 Unknown
lodash.snakecase@4.1.1 Unknown
lodash.startcase@4.4.0 Unknown
lodash.uniq@4.5.0 Unknown
lodash.upperfirst@4.3.1 Unknown

Total size change: 19.9 MB

Comment thread packages/testing/package.json Outdated
"@types/lodash-es": "^4.17.6",
"@types/node": "^22.12.0",
"ava": "^5.0.0",
"c8": "^10.0.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c8 wasn't used in this package

Comment thread package.json
Comment on lines -49 to -50
"@commitlint/cli": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed husky in #6464 and orphaned this

Comment thread package.json
"@commitlint/config-conventional": "^19.0.0",
"@eslint/compat": "^1.2.9",
"@eslint/js": "^9.28.0",
"@typescript-eslint/eslint-plugin": "~8.49.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed when using typescript-eslint

@serhalp
serhalp force-pushed the serhalp/refactor/remove-unused-and-configure-knip branch from d601446 to dd29887 Compare June 26, 2026 22:56
@github-actions

Copy link
Copy Markdown
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@serhalp
serhalp force-pushed the serhalp/refactor/remove-unused-and-configure-knip branch from b3bd4e2 to 8b3c43a Compare June 29, 2026 20:46
serhalp added 9 commits June 30, 2026 07:15
- c8 wasn't used in that package
- typescript was assumed to be hoisted in the root but was declared instead as a dev dep in many
  (but not all) individual packages
- ts-node was missing from one package, just happened to work due to hoisting
This was left over from the deletion in a00e0ea.
@serhalp
serhalp force-pushed the serhalp/refactor/remove-unused-and-configure-knip branch from 8b3c43a to 7b78ce3 Compare June 30, 2026 11:15
@@ -1,6 +1,5 @@
export enum BundleFormat {
ESZIP2 = 'eszip2',
JS = 'js',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover deletion from 2022 removal in a00e0ea

@serhalp
serhalp force-pushed the serhalp/refactor/remove-unused-and-configure-knip branch from 54f81b5 to f496251 Compare June 30, 2026 11:24
@serhalp
serhalp marked this pull request as ready for review June 30, 2026 13:11
@serhalp
serhalp requested a review from a team as a code owner June 30, 2026 13:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/edge-bundler/node/validation/manifest/index.test.ts (1)

14-15: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a regression case for the removed js format.

The valid fixture now covers eszip2, but the invalid-format test still uses arbitrary foo; it would not fail if js were accidentally allowed again.

Suggested test addition
 describe('bundle', () => {
+  test('should throw on removed js format', () => {
+    const manifest = getBaseManifest()
+    manifest.bundles[0].asset = 'function.js'
+    manifest.bundles[0].format = 'js'
+
+    expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot()
+  })
+
   test('should throw on additional property in bundle', () => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/edge-bundler/node/validation/manifest/index.test.ts` around lines 14
- 15, The manifest validation tests need a regression case for the removed js
format, since the current invalid-format coverage only checks an arbitrary value
and would miss js being reallowed. Update the manifest validation test in
index.test.ts to explicitly assert that js is rejected, alongside the existing
eszip2 fixture coverage, using the manifest validation path exercised by the
current test cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.agents/skills/knip/SKILL.md:
- Around line 14-18: The knip skill guide is using a bare npx-based availability
check even though the repo already provides a lockfile-backed knip dependency
and npm script. Update the setup and command examples in SKILL.md to use the
local script path via npm run knip -- ... (or the repo’s equivalent script), and
remove the npx knip --version check so the documented workflow stays pinned to
the repo-local installation.

In @.github/workflows/conventional-commit.yml:
- Around line 10-12: The conventional-commit workflow currently runs npm ci
before ensuring a specific Node version is installed, so the job depends on
whatever Node/npm is preinstalled on the runner. Update the job to add
actions/setup-node before the Install Dependencies step, using the same Node
version/pinning approach as the other workflows in this repo, and keep the
existing actions/checkout step followed by setup-node and then npm ci.

In @.github/workflows/knip.yml:
- Around line 14-16: The Knip workflow’s checkout step is leaving credentials
persisted by default, which keeps the GitHub token in local git config during
pull_request builds. Update the existing actions/checkout step in the knip job
to disable credential persistence by setting persist-credentials to false. Keep
the change scoped to the checkout configuration so the rest of the workflow
behavior stays the same.

---

Nitpick comments:
In `@packages/edge-bundler/node/validation/manifest/index.test.ts`:
- Around line 14-15: The manifest validation tests need a regression case for
the removed js format, since the current invalid-format coverage only checks an
arbitrary value and would miss js being reallowed. Update the manifest
validation test in index.test.ts to explicitly assert that js is rejected,
alongside the existing eszip2 fixture coverage, using the manifest validation
path exercised by the current test cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d74fc97e-8f6d-4382-ad83-23d7b5a543c0

📥 Commits

Reviewing files that changed from the base of the PR and between 677f1bd and f496251.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • packages/edge-bundler/node/validation/manifest/__snapshots__/index.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (40)
  • .agents/skills/knip/SKILL.md
  • .claude/skills/knip
  • .github/workflows/conventional-commit.yml
  • .github/workflows/knip.yml
  • knip.jsonc
  • package.json
  • packages/build-info/package.json
  • packages/build-info/playwright.config.ts
  • packages/build-info/vitest.config.ts
  • packages/build/src/log/logger.ts
  • packages/build/src/plugins_core/frameworks_api/skew_protection.ts
  • packages/build/tests/unit/validate_edge_manifest/tests.js
  • packages/cache-utils/package.json
  • packages/config/package.json
  • packages/config/src/api/site_info.ts
  • packages/config/src/log/messages.js
  • packages/edge-bundler/node/bundle.ts
  • packages/edge-bundler/node/utils/sha256.ts
  • packages/edge-bundler/node/validation/manifest/index.test.ts
  • packages/edge-bundler/node/validation/manifest/schema.ts
  • packages/edge-bundler/package.json
  • packages/edge-bundler/shared/consts.ts
  • packages/functions-utils/package.json
  • packages/git-utils/package.json
  • packages/headers-parser/package.json
  • packages/js-client/package.json
  • packages/js-client/tsconfig.json
  • packages/nock-udp/package.json
  • packages/opentelemetry-sdk-setup/package.json
  • packages/opentelemetry-utils/package.json
  • packages/redirect-parser/package.json
  • packages/run-utils/package.json
  • packages/testing/package.json
  • packages/zip-it-and-ship-it/package.json
  • packages/zip-it-and-ship-it/src/config.ts
  • packages/zip-it-and-ship-it/src/runtimes/node/in_source_config/index.ts
  • packages/zip-it-and-ship-it/src/runtimes/node/parser/index.ts
  • packages/zip-it-and-ship-it/src/runtimes/node/utils/entry_file.ts
  • packages/zip-it-and-ship-it/src/utils/timer.ts
  • skills-lock.json
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • netlify/blueprints (manual)
💤 Files with no reviewable changes (22)
  • packages/edge-bundler/node/bundle.ts
  • packages/edge-bundler/shared/consts.ts
  • packages/zip-it-and-ship-it/src/runtimes/node/utils/entry_file.ts
  • packages/headers-parser/package.json
  • packages/config/src/api/site_info.ts
  • packages/config/src/log/messages.js
  • packages/run-utils/package.json
  • packages/redirect-parser/package.json
  • packages/cache-utils/package.json
  • packages/zip-it-and-ship-it/src/runtimes/node/in_source_config/index.ts
  • packages/zip-it-and-ship-it/src/utils/timer.ts
  • packages/opentelemetry-utils/package.json
  • packages/edge-bundler/node/utils/sha256.ts
  • packages/git-utils/package.json
  • packages/build/src/plugins_core/frameworks_api/skew_protection.ts
  • packages/build/src/log/logger.ts
  • packages/nock-udp/package.json
  • packages/functions-utils/package.json
  • packages/zip-it-and-ship-it/src/config.ts
  • packages/edge-bundler/package.json
  • packages/zip-it-and-ship-it/package.json
  • packages/opentelemetry-sdk-setup/package.json

Comment thread .agents/skills/knip/SKILL.md
Comment thread .github/workflows/conventional-commit.yml
Comment thread .github/workflows/knip.yml
@serhalp serhalp self-assigned this Jul 16, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@netlify/build

npm i https://pkg.pr.new/@netlify/build@7117

@netlify/build-info

npm i https://pkg.pr.new/@netlify/build-info@7117

@netlify/cache-utils

npm i https://pkg.pr.new/@netlify/cache-utils@7117

@netlify/config

npm i https://pkg.pr.new/@netlify/config@7117

@netlify/edge-bundler

npm i https://pkg.pr.new/@netlify/edge-bundler@7117

@netlify/functions-utils

npm i https://pkg.pr.new/@netlify/functions-utils@7117

@netlify/git-utils

npm i https://pkg.pr.new/@netlify/git-utils@7117

@netlify/headers-parser

npm i https://pkg.pr.new/@netlify/headers-parser@7117

@netlify/api

npm i https://pkg.pr.new/@netlify/api@7117

@netlify/nock-udp

npm i https://pkg.pr.new/@netlify/nock-udp@7117

@netlify/opentelemetry-sdk-setup

npm i https://pkg.pr.new/@netlify/opentelemetry-sdk-setup@7117

@netlify/opentelemetry-utils

npm i https://pkg.pr.new/@netlify/opentelemetry-utils@7117

@netlify/redirect-parser

npm i https://pkg.pr.new/@netlify/redirect-parser@7117

@netlify/run-utils

npm i https://pkg.pr.new/@netlify/run-utils@7117

@netlify/zip-it-and-ship-it

npm i https://pkg.pr.new/@netlify/zip-it-and-ship-it@7117

commit: 3bcc73e

serhalp and others added 2 commits August 4, 2026 15:47
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@43081j 43081j left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@serhalp
serhalp enabled auto-merge (squash) August 6, 2026 10:38
@serhalp
serhalp merged commit 7418c9d into main Aug 6, 2026
63 of 65 checks passed
@serhalp
serhalp deleted the serhalp/refactor/remove-unused-and-configure-knip branch August 6, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants