-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknip.ts
61 lines (59 loc) · 1.69 KB
/
knip.ts
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
import type { KnipConfig } from 'knip';
const config: KnipConfig = {
// Entry files are the starting point for dependency analysis
// Using more specific entry patterns rather than including everything
entry: [
'src/app/layout.tsx',
'src/app/page.tsx',
'src/app/**/page.tsx',
'src/app/**/layout.tsx',
'src/app/api/**/route.ts',
],
// Project files define the scope of what can be considered "unused"
project: [
'src/**/*.{ts,tsx}!', // Production files with ! suffix
'!src/**/*.{test,spec}.{ts,tsx}', // Exclude test files
'!src/**/__tests__/**',
],
// Dependencies to ignore from unused checks
ignoreDependencies: [
'@types/*',
'prettier-plugin-tailwindcss',
// Common Next.js dependencies that may appear unused
'next',
'react',
'react-dom',
],
// Files to ignore from issue reporting
ignore: [
'**/*.d.ts',
'**/generated/**', // Generated files
'src/lib/types/**', // Type definition files
],
ignoreExportsUsedInFile: true,
// Workspace configuration for monorepo support
workspaces: {
// Configure specific rules per workspace if needed
'.': {
entry: [
'src/app/layout.tsx',
'src/app/page.tsx',
'src/app/**/page.tsx',
'src/app/**/layout.tsx',
'src/app/api/**/route.ts',
],
},
},
rules: {
classMembers: 'warn',
exports: 'error',
files: 'error',
types: 'error',
dependencies: 'error',
// Additional rules for better coverage
unlisted: 'error', // Report unlisted dependencies
duplicates: 'warn', // Warn about duplicate dependencies
nsExports: 'error', // Check namespace exports
},
} as const;
export default config;