From 7b5cb95ff7144bf98efc435b9fcb50fe75434416 Mon Sep 17 00:00:00 2001 From: Sundaram Kumar Jha Date: Fri, 21 Aug 2026 08:17:02 +0000 Subject: [PATCH] chore(tooling): add Knip configuration to detect unused files and dependencies --- .agents/skills/databuddy-internal/SKILL.md | 1 + knip.json | 100 +++++++++++++++++++++ package.json | 2 +- 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 knip.json diff --git a/.agents/skills/databuddy-internal/SKILL.md b/.agents/skills/databuddy-internal/SKILL.md index d22ccd000..3743b6691 100644 --- a/.agents/skills/databuddy-internal/SKILL.md +++ b/.agents/skills/databuddy-internal/SKILL.md @@ -77,6 +77,7 @@ Keep additions **minimal**: one bullet, a new `rg` hint, or a routing note—eno - `packages/sdk`: published analytics SDK for React, Vue, and Node - `packages/tracker`: internal tracker script build and release package - `packages/encryption`, `packages/notifications`, `packages/cache`, `packages/redis`, `packages/services`, `packages/validation`, `packages/api-keys`: shared infra and domain packages +- Knip is configured in root `knip.json` (run `bun run knip`); per-workspace test globs are required because the root `test:watch` (`bun test --watch ./apps`) script shadows the Bun plugin's per-workspace script parsing; `apps/cron` is ignored (standalone scripts, no package.json) Read [codebase-map.md](./references/codebase-map.md) when you need deeper routing guidance. diff --git a/knip.json b/knip.json new file mode 100644 index 000000000..1631e33cd --- /dev/null +++ b/knip.json @@ -0,0 +1,100 @@ +{ + "$schema": "./node_modules/knip/schema.json", + "workspaces": { + ".": { + "entry": ["scripts/**/*.ts"], + "ignore": ["apps/cron/**"], + "ignoreBinaries": ["where", "which", "up"] + }, + "apps/dashboard": { + "entry": ["**/*.test.{ts,tsx}"], + "ignoreDependencies": ["topojson-specification"] + }, + "apps/docs": { + "entry": ["source.config.ts", "content/**/*.mdx", "**/*.test.{ts,tsx}"] + }, + "apps/insights": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "apps/links": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "apps/slack": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "apps/uptime": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "apps/video": { + "entry": ["remotion.config.ts", "src/index.ts"], + "ignoreBinaries": ["out/intelligence-platform.mp4"] + }, + "packages/ai": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/api-keys": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/db": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/devtools": { + "entry": ["src/{core,react,vue}/index.ts"] + }, + "packages/email": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/encryption": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/env": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/migrate": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/notifications": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/nuxt": { + "entry": [ + "src/module.ts", + "src/runtime/**/*.ts", + "playground/**/*.{ts,vue}" + ] + }, + "packages/redis": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/rpc": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/sdk": { + "entry": [ + "src/{core,node,react,vue}/index.ts", + "test-entry.ts", + "tests/**/*.test.{ts,tsx}", + "tests/**/*.types.ts" + ] + }, + "packages/services": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/shared": { + "entry": ["**/*.test.{ts,tsx}"] + }, + "packages/tracker": { + "entry": [ + "src/{errors,index,vitals}.ts", + "test-server.ts", + "tests/unit/**/*.test.ts" + ] + }, + "packages/ui": { + "ignoreDependencies": ["tailwindcss", "tw-animate-css"] + }, + "packages/validation": { + "entry": ["**/*.test.{ts,tsx}"] + } + } +} diff --git a/package.json b/package.json index 85a9b6f52..9067998e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "databuddy", - "module": "index.ts", "devDependencies": { "@babel/plugin-proposal-optional-chaining": "^7.21.0", "@babel/plugin-transform-react-jsx": "^7.28.6", @@ -44,6 +43,7 @@ "test:watch": "dotenv -- bun test --watch ./apps", "test:coverage": "dotenv -- bun test --coverage ./apps", "lint": "bunx ultracite check && bun run lint:policies", + "knip": "knip", "lint:policies": "bunx tsc --project scripts/tsconfig.json && bun test scripts/lint-policy.test.ts && bun scripts/lint-policy.ts", "format": "bunx ultracite fix", "check-types": "dotenv -- turbo run check-types",