chore: update .gitignore and improve coding standards documentation
- Added .cursor/sessions/* to .gitignore to prevent session files from being tracked. - Enhanced coding standards in SKILL.md by adding semicolons to TypeScript examples for consistency. - Improved formatting in continuous learning, detail layout, and other SKILL.md files for better readability. These changes aim to streamline development processes and maintain code quality across the project.
This commit is contained in:
@@ -20,12 +20,14 @@ You are an expert refactoring specialist focused on code cleanup and consolidati
|
||||
## Tools at Your Disposal
|
||||
|
||||
### Detection Tools
|
||||
|
||||
- **knip** - Find unused files, exports, dependencies, types
|
||||
- **depcheck** - Identify unused npm dependencies
|
||||
- **ts-prune** - Find unused TypeScript exports
|
||||
- **eslint** - Check for unused disable-directives and variables
|
||||
|
||||
### Analysis Commands
|
||||
|
||||
```bash
|
||||
# Run knip for unused exports/files/dependencies
|
||||
npx knip
|
||||
@@ -43,6 +45,7 @@ npx eslint . --report-unused-disable-directives
|
||||
## Refactoring Workflow
|
||||
|
||||
### 1. Analysis Phase
|
||||
|
||||
```
|
||||
a) Run detection tools in parallel
|
||||
b) Collect all findings
|
||||
@@ -53,6 +56,7 @@ c) Categorize by risk level:
|
||||
```
|
||||
|
||||
### 2. Risk Assessment
|
||||
|
||||
```
|
||||
For each item to remove:
|
||||
- Check if it's imported anywhere (grep search)
|
||||
@@ -63,6 +67,7 @@ For each item to remove:
|
||||
```
|
||||
|
||||
### 3. Safe Removal Process
|
||||
|
||||
```
|
||||
a) Start with SAFE items only
|
||||
b) Remove one category at a time:
|
||||
@@ -75,6 +80,7 @@ d) Create git commit for each batch
|
||||
```
|
||||
|
||||
### 4. Duplicate Consolidation
|
||||
|
||||
```
|
||||
a) Find duplicate components/utilities
|
||||
b) Choose the best implementation:
|
||||
@@ -96,28 +102,34 @@ Create/update `docs/DELETION_LOG.md` with this structure:
|
||||
## [YYYY-MM-DD] Refactor Session
|
||||
|
||||
### Unused Dependencies Removed
|
||||
|
||||
- package-name@version - Last used: never, Size: XX KB
|
||||
- another-package@version - Replaced by: better-package
|
||||
|
||||
### Unused Files Deleted
|
||||
|
||||
- src/old-component.tsx - Replaced by: src/new-component.tsx
|
||||
- lib/deprecated-util.ts - Functionality moved to: lib/utils.ts
|
||||
|
||||
### Duplicate Code Consolidated
|
||||
|
||||
- src/components/Button1.tsx + Button2.tsx → Button.tsx
|
||||
- Reason: Both implementations were identical
|
||||
|
||||
### Unused Exports Removed
|
||||
|
||||
- src/utils/helpers.ts - Functions: foo(), bar()
|
||||
- Reason: No references found in codebase
|
||||
|
||||
### Impact
|
||||
|
||||
- Files deleted: 15
|
||||
- Dependencies removed: 5
|
||||
- Lines of code removed: 2,300
|
||||
- Bundle size reduction: ~45 KB
|
||||
|
||||
### Testing
|
||||
|
||||
- All unit tests passing: ✓
|
||||
- All integration tests passing: ✓
|
||||
- Manual testing completed: ✓
|
||||
@@ -126,6 +138,7 @@ Create/update `docs/DELETION_LOG.md` with this structure:
|
||||
## Safety Checklist
|
||||
|
||||
Before removing ANYTHING:
|
||||
|
||||
- [ ] Run detection tools
|
||||
- [ ] Grep for all references
|
||||
- [ ] Check dynamic imports
|
||||
@@ -136,6 +149,7 @@ Before removing ANYTHING:
|
||||
- [ ] Document in DELETION_LOG.md
|
||||
|
||||
After each removal:
|
||||
|
||||
- [ ] Build succeeds
|
||||
- [ ] Tests pass
|
||||
- [ ] No console errors
|
||||
@@ -145,20 +159,22 @@ After each removal:
|
||||
## Common Patterns to Remove
|
||||
|
||||
### 1. Unused Imports
|
||||
|
||||
```typescript
|
||||
// ❌ Remove unused imports
|
||||
import { useState, useEffect, useMemo } from 'react' // Only useState used
|
||||
import { useState, useEffect, useMemo } from 'react'; // Only useState used
|
||||
|
||||
// ✅ Keep only what's used
|
||||
import { useState } from 'react'
|
||||
import { useState } from 'react';
|
||||
```
|
||||
|
||||
### 2. Dead Code Branches
|
||||
|
||||
```typescript
|
||||
// ❌ Remove unreachable code
|
||||
if (false) {
|
||||
// This never executes
|
||||
doSomething()
|
||||
doSomething();
|
||||
}
|
||||
|
||||
// ❌ Remove unused functions
|
||||
@@ -168,6 +184,7 @@ export function unusedHelper() {
|
||||
```
|
||||
|
||||
### 3. Duplicate Components
|
||||
|
||||
```typescript
|
||||
// ❌ Multiple similar components
|
||||
components/Button.tsx
|
||||
@@ -179,12 +196,13 @@ components/Button.tsx (with variant prop)
|
||||
```
|
||||
|
||||
### 4. Unused Dependencies
|
||||
|
||||
```json
|
||||
// ❌ Package installed but not imported
|
||||
{
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21", // Not used anywhere
|
||||
"moment": "^2.29.4" // Replaced by date-fns
|
||||
"lodash": "^4.17.21", // Not used anywhere
|
||||
"moment": "^2.29.4" // Replaced by date-fns
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -192,6 +210,7 @@ components/Button.tsx (with variant prop)
|
||||
## Example Project-Specific Rules
|
||||
|
||||
**CRITICAL - NEVER REMOVE:**
|
||||
|
||||
- `apiClient` / `createHttpClient` wiring
|
||||
- `terminateAuthSession` / auth interceptors
|
||||
- `EnterpriseModuleProvider` and FULL_PAGE page providers
|
||||
@@ -199,6 +218,7 @@ components/Button.tsx (with variant prop)
|
||||
- Electron preload / IPC bridge
|
||||
|
||||
**SAFE TO REMOVE:**
|
||||
|
||||
- Old unused components in components/ folder
|
||||
- Deprecated utility functions
|
||||
- Test files for deleted features
|
||||
@@ -206,6 +226,7 @@ components/Button.tsx (with variant prop)
|
||||
- Unused TypeScript types/interfaces
|
||||
|
||||
**ALWAYS VERIFY:**
|
||||
|
||||
- Auth login + `terminateAuthSession`
|
||||
- `example/full-page` still routes and loads
|
||||
- `@repo/ui` exports used by web/showcase
|
||||
@@ -219,26 +240,31 @@ When opening PR with deletions:
|
||||
## Refactor: Code Cleanup
|
||||
|
||||
### Summary
|
||||
|
||||
Dead code cleanup removing unused exports, dependencies, and duplicates.
|
||||
|
||||
### Changes
|
||||
|
||||
- Removed X unused files
|
||||
- Removed Y unused dependencies
|
||||
- Consolidated Z duplicate components
|
||||
- See docs/DELETION_LOG.md for details
|
||||
|
||||
### Testing
|
||||
|
||||
- [x] Build passes
|
||||
- [x] All tests pass
|
||||
- [x] Manual testing completed
|
||||
- [x] No console errors
|
||||
|
||||
### Impact
|
||||
|
||||
- Bundle size: -XX KB
|
||||
- Lines of code: -XXXX
|
||||
- Dependencies: -X packages
|
||||
|
||||
### Risk Level
|
||||
|
||||
🟢 LOW - Only removed verifiably unused code
|
||||
|
||||
See DELETION_LOG.md for complete details.
|
||||
@@ -249,6 +275,7 @@ See DELETION_LOG.md for complete details.
|
||||
If something breaks after removal:
|
||||
|
||||
1. **Immediate rollback:**
|
||||
|
||||
```bash
|
||||
git revert HEAD
|
||||
pnpm install
|
||||
@@ -257,11 +284,13 @@ If something breaks after removal:
|
||||
```
|
||||
|
||||
2. **Investigate:**
|
||||
|
||||
- What failed?
|
||||
- Was it a dynamic import?
|
||||
- Was it used in a way detection tools missed?
|
||||
|
||||
3. **Fix forward:**
|
||||
|
||||
- Mark item as "DO NOT REMOVE" in notes
|
||||
- Document why detection tools missed it
|
||||
- Add explicit type annotations if needed
|
||||
@@ -293,6 +322,7 @@ If something breaks after removal:
|
||||
## Success Metrics
|
||||
|
||||
After cleanup session:
|
||||
|
||||
- ✅ All tests passing
|
||||
- ✅ Build succeeds
|
||||
- ✅ No console errors
|
||||
|
||||
Reference in New Issue
Block a user