Add knip and clean up unused code#117
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces knip, a tool for detecting unused code, and performs comprehensive cleanup of unused exports, imports, types, and entire files. The changes improve code maintainability by removing dead code while ensuring all remaining code is properly referenced.
Changes:
- Added knip configuration and tooling to detect unused code
- Removed unused files: graph-api.test.ts, metrics-api.ts, types.ts, graph-api.ts, client.ts
- Removed unused functions and types from existing files
- Converted default exports to named exports for consistency
- Fixed Jest config paths and moved test dependencies to devDependencies
Reviewed changes
Copilot reviewed 26 out of 28 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| knip.json | New knip configuration with proper entry points, ignore patterns, and Jest integration |
| package.json | Added knip script, moved test dependencies to devDependencies, updated TypeScript and @types/node |
| package-lock.json | Updated lockfile with knip and its dependencies |
| plugins/aks-desktop/package.json | Moved jest-environment-jsdom and ts-jest from dependencies to devDependencies |
| plugins/aks-desktop/test-config/jest/jest.config.babel.js | Fixed rootDir and setupFilesAfterEnv paths |
| plugins/aks-desktop/src/utils/test/graph-api.test.ts | Deleted unused test file (861 lines) |
| plugins/aks-desktop/src/utils/shared/metrics-api.ts | Deleted unused metrics API file (742 lines) |
| plugins/aks-desktop/src/utils/azure/types.ts | Deleted unused type definitions file (75 lines) |
| plugins/aks-desktop/src/utils/azure/graph-api.ts | Deleted unused Graph API implementation (231 lines) |
| plugins/aks-desktop/src/utils/azure/client.ts | Deleted unused Azure client factory (146 lines) |
| plugins/aks-desktop/src/utils/azure/aks.ts | Removed unused AzureResult type and deprecated getAKSKubeconfig function |
| plugins/aks-desktop/src/hooks/useAzureAuth.tsx | Removed unused React import and withAzureAuth HOC |
| plugins/aks-desktop/src/components/CreateAKSProject/validators.ts | Removed unused functions: validateEmail, sanitizeProjectName, isValidKubernetesName; removed unused EmailValidationResult import |
| plugins/aks-desktop/src/components/CreateAKSProject/types.ts | Removed unused types: StepValidation, CreationState, AssignmentRowProps, EmailValidationResult, AzureApiResponse types, StepName |
| plugins/aks-desktop/src/components/CreateAKSProject/components/*.tsx | Removed duplicate default exports, keeping only named exports |
| plugins/aks-desktop/src/components/InfoTab/InfoTab.tsx | Changed imports from default to named exports |
| plugins/aks-desktop/src/components/DeployWizard/DeployWizard.tsx | Changed Breadcrumb import from default to named export |
| plugins/aks-desktop/src/components/CreateAKSProject/CreateAKSProject.tsx | Changed all component imports from default to named exports |
Files not reviewed (1)
- plugins/aks-desktop/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- plugins/aks-desktop/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The merge-base changed after approval.
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- plugins/aks-desktop/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Saw this by accident the other day and it inspired me to add https://github.com/webpro-nl/knip/blob/31eaaf544c88bd4c26003025da515a0f8ac134dd/packages/create-config/index.js#L154-L164 In other words, in a "faux monorepo" like this, config could be improved by adding |

These changes do the following:
Fixes: #35
Testing
npm run knipNote
NOTICE.mdshould be regenerated before release