Commit graph

3 commits

Author SHA1 Message Date
Brandon Pereira
e856091d1c
chore: refactor knip CI to fail on issues and simplify comment format (#2003)
## Summary

Simplify the knip GitHub Action and expand where it runs:

- **Remove main-branch comparison** — knip now reports all issues found on the current branch rather than diffing against main. This makes the output more straightforward and actionable.
- **Fail on errors** — the job calls `core.setFailed()` when knip finds issues, so the check shows as failed on the PR.
- **Run on push to main** — added `push` trigger so knip also runs when commits land on main.
- **Support fork PRs** — on fork PRs, the GITHUB_TOKEN can't write to the base repo, so the action skips PR commenting and logs results to the Actions console instead.

### How to test locally or on Vercel

1. Open a PR from a non-fork branch — knip should comment on the PR with results
2. Push to main — knip should run and log results to the Actions console without attempting to comment
3. (Fork PR) — knip should run, log results to the console, and skip commenting

### References

- Related PRs:
2026-04-01 17:12:40 +00:00
Brandon Pereira
c72d7baa7f
chore: resolve remaining knip issues (#1991)
## Summary

Resolve all remaining knip issues — removes unused exports/types, adds missing direct dependencies, deletes dead code, and updates knip config.

**Dependency fixes:**
- Root: swapped unused `eslint-config-next`/`eslint-plugin-react-hooks` for actually-imported `@eslint/js`, `typescript-eslint`, `tslib`
- App: added directly-used transitive deps (`@codemirror/*`, `react-resizable`, `postcss-simple-vars`, `rimraf`, `serve`, `@next/eslint-plugin-next`, `eslint-plugin-react`); removed unused `@storybook/react`

**Dead code removal:**
- Removed ~100 unused exports/types across api and app packages (removed `export` keyword where used locally, deleted entirely where not)
- Fixed duplicate `DBRowTableIconButton` default+named export; updated consumers to use named import

**knip.json updates:**
- Added `fixtures.ts` entry point and `opamp/**` ignore for api package
- Excluded `enumMembers` and `duplicates` issue types
- Enabled `ignoreExportsUsedInFile`

### How to test locally or on Vercel

1. `yarn install && yarn knip` — should produce zero output
2. `make ci-lint` — all packages pass
3. `make ci-unit` — all unit tests pass
2026-03-27 20:17:47 +00:00
Brandon Pereira
b642ce43d3
feat: Add Knip for unused code analysis with CI reporting (#1954)
## Summary

Adds [Knip](https://knip.dev) to the monorepo to detect unused files, dependencies, and exports. The goal is to reduce dead code over time and prevent new unused code from accumulating.

**What's included:**
- Root-level `knip.json` configured for all three workspaces (`packages/app`, `packages/api`, `packages/common-utils`)
- `yarn knip` and `yarn knip:ci` scripts for local and CI usage
- GitHub Action (`.github/workflows/knip.yml`) that runs on every PR to `main`, compares results against the base branch, and posts a summary comment showing any increase or decrease in unused code
- Removed the previous app-only `packages/app/knip.json` in favor of the monorepo-wide config

**How the CI workflow works:**
1. Runs Knip on the PR branch
2. Checks out `main` and runs Knip there
3. Compares issue counts per category and posts/updates a PR comment with a diff table

This is additive — Knip runs as an informational check and does not block PRs.
2026-03-23 14:41:44 +00:00