-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathknip.ts
More file actions
118 lines (107 loc) · 3.33 KB
/
knip.ts
File metadata and controls
118 lines (107 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import type { KnipConfig } from 'knip';
const config: KnipConfig = {
ignore: [
// Used via TypeScript path mapping in tsconfig.scripts.json ("server-only" -> this file)
'src/scripts/lib/server-only-shim.ts',
],
// Ignore dependencies that are used indirectly or intentionally unused
ignoreDependencies: [
// Used via plugins or extends (detected by custom compiler now)
'eslint-config-prettier',
// Alternative test runner
'ts-jest',
// Used in client-side code
'client-only',
// Used in scripts
'dotenv/config',
],
// Binaries that are used but not listed in dependencies
ignoreBinaries: [
'cmp', // System command used in GitHub workflows
'stripe', // Stripe CLI tool
'only-allow', // Package manager enforcement
],
// Ignore exports that might be used by Next.js or imported dynamically
ignoreExportsUsedInFile: {
interface: true,
type: true,
},
// Custom compilers to detect dependencies in non-JS files
compilers: {
// Parse CSS files to detect @plugin directives for Tailwind v4
css: (text: string) => {
const plugins = [...text.matchAll(/@(plugin|import)\s+['"]([^'"]+)['"]/g)].map(m => m[2]);
return plugins.map(plugin => `import '${plugin}';`).join('\n');
},
},
typescript: {
config: ['tsconfig.json', 'tsconfig.scripts.json'],
},
// Workspace configuration
workspaces: {
'.': {
entry: [
// Scripts are valid dev-only entry points
'src/scripts/**/*.ts',
'!src/scripts/index.ts',
],
project: [
'src/**/*.{js,jsx,ts,tsx,css}',
'!src/scripts/**', // Scripts are entry points, not project files
'*.{js,mjs,ts,tsx}',
],
},
storybook: {
entry: [
'stories/**/*.stories.@(ts|tsx)',
'src/**/*.{ts,tsx}', // Storybook-specific decorators and utilities
],
project: [
'**/*.{ts,tsx,js,jsx}',
// Exclude parent project patterns that storybook's tsconfig includes but shouldn't analyze
'!../{src/scripts,supabase}/**',
],
ignoreDependencies: [
// Used by Chromatic GitHub Action, not directly imported in code
'@chromatic-com/storybook',
],
},
'cloud-agent': {
entry: ['src/index.ts', 'test/**/*.test.ts'],
ignoreDependencies: ['cloudflare', '@vitest/coverage-v8'],
},
'cloudflare-ai-attribution': {
entry: ['src/ai-attribution.worker.ts'],
ignoreDependencies: ['cloudflare'],
},
'cloudflare-app-builder': {
entry: ['src/index.ts'],
ignoreDependencies: ['cloudflare'],
},
'cloudflare-auto-fix-infra': {
entry: ['src/index.ts'],
ignoreDependencies: ['cloudflare'],
},
'cloudflare-auto-triage-infra': {
entry: ['src/index.ts'],
ignoreDependencies: ['cloudflare'],
},
'cloudflare-code-review-infra': {
entry: ['src/index.ts'],
ignoreDependencies: ['cloudflare'],
},
'cloudflare-db-proxy': {
entry: ['src/index.ts'],
ignoreDependencies: ['cloudflare', '@cloudflare/vitest-pool-workers'],
},
'cloudflare-deploy-infra/builder': {
entry: ['src/index.ts'],
ignoreDependencies: ['cloudflare'],
},
'cloudflare-deploy-infra/dispatcher': {
entry: ['src/index.ts'],
ignoreBinaries: ['wrangler'],
},
},
};
export default config;