Skip to content

Commit c7baf3c

Browse files
authored
[feat] Add knip for unused code detection (#4890)
1 parent 8403bd0 commit c7baf3c

File tree

14 files changed

+615
-996
lines changed

14 files changed

+615
-996
lines changed

.github/workflows/lint-and-format.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
run: |
5757
npm run lint
5858
npm run format:check
59+
npm run knip
5960
6061
- name: Comment on PR about auto-fix
6162
if: steps.verify-changed-files.outputs.changed == 'true' && github.event.pull_request.head.repo.full_name == github.repository

knip.config.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import type { KnipConfig } from 'knip'
2+
3+
const config: KnipConfig = {
4+
entry: [
5+
'src/main.ts',
6+
'vite.config.mts',
7+
'vite.electron.config.mts',
8+
'vite.types.config.mts',
9+
'eslint.config.js',
10+
'tailwind.config.js',
11+
'postcss.config.js',
12+
'playwright.config.ts',
13+
'playwright.i18n.config.ts',
14+
'vitest.config.ts',
15+
'scripts/**/*.{js,ts}'
16+
],
17+
project: [
18+
'src/**/*.{js,ts,vue}',
19+
'tests-ui/**/*.{js,ts,vue}',
20+
'browser_tests/**/*.{js,ts}',
21+
'scripts/**/*.{js,ts}'
22+
],
23+
ignore: [
24+
// Generated files
25+
'dist/**',
26+
'types/**',
27+
'node_modules/**',
28+
// Config files that might not show direct usage
29+
'.husky/**',
30+
// Temporary or cache files
31+
'.vite/**',
32+
'coverage/**',
33+
// i18n config
34+
'.i18nrc.cjs',
35+
// Test setup files
36+
'browser_tests/globalSetup.ts',
37+
'browser_tests/globalTeardown.ts',
38+
'browser_tests/utils/**',
39+
// Scripts
40+
'scripts/**',
41+
// Vite config files
42+
'vite.electron.config.mts',
43+
'vite.types.config.mts',
44+
// Auto generated manager types
45+
'src/types/generatedManagerTypes.ts'
46+
],
47+
ignoreExportsUsedInFile: true,
48+
// Vue-specific configuration
49+
vue: true,
50+
// Only check for unused files, disable all other rules
51+
// TODO: Gradually enable other rules - see https://github.com/Comfy-Org/ComfyUI_frontend/issues/4888
52+
rules: {
53+
binaries: 'off',
54+
classMembers: 'off',
55+
dependencies: 'off',
56+
devDependencies: 'off',
57+
duplicates: 'off',
58+
enumMembers: 'off',
59+
exports: 'off',
60+
nsExports: 'off',
61+
nsTypes: 'off',
62+
types: 'off',
63+
unlisted: 'off'
64+
},
65+
// Include dependencies analysis
66+
includeEntryExports: true,
67+
// Workspace configuration for monorepo-like structure
68+
workspaces: {
69+
'.': {
70+
entry: ['src/main.ts']
71+
}
72+
}
73+
}
74+
75+
export default config

0 commit comments

Comments
 (0)