Skip to content

Commit a14d079

Browse files
committed
updated code cleanup rules
1 parent ee68880 commit a14d079

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

guides/routines/cleanup-improve-code-quality.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,48 @@ const count = users.length; // Number - no useMemo
213213
- Check for dynamic imports or require statements
214214
3. **Delete the file** if it is not used anywhere in the codebase
215215

216+
**CRITICAL: Files to NEVER delete**
217+
Before proceeding with any file deletion, verify the file is NOT one of these protected types:
218+
219+
**Configuration Files:**
220+
221+
- `package.json`, `package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`
222+
- `tsconfig.json`, `tsconfig.*.json`
223+
- `next.config.js`, `next.config.ts`, `next.config.mjs`
224+
- `tailwind.config.js`, `postcss.config.js`, `eslint.config.js`
225+
- `biome.json`, `.eslintrc.*`, `.prettierrc.*`
226+
- `vite.config.*`, `webpack.config.*`, `rollup.config.*`
227+
- `.env*`, `.env.local`, `.env.production`, etc.
228+
- `nx.json`, `project.json`, `workspace.json`
229+
230+
**Entry Point Files:**
231+
232+
- `index.ts`, `index.tsx`, `index.js`, `index.jsx`
233+
- `main.ts`, `main.tsx`, `main.js`, `main.jsx`
234+
- `app.ts`, `app.tsx`, `app.js`, `app.jsx`
235+
- `server.ts`, `server.tsx`, `server.js`, `server.jsx`
236+
237+
**Generated Files:**
238+
239+
- Files in `_generated/` directories
240+
- Files in `node_modules/` directories
241+
- Files in `.next/`, `dist/`, `build/`, `out/` directories
242+
- Files with `.d.ts` extensions (TypeScript declaration files)
243+
- Files in `convex/_generated/` directories
244+
245+
**Framework-Specific Files:**
246+
247+
- `page.tsx`, `page.ts`, `page.js`, `page.jsx` (Next.js App Router)
248+
- `layout.tsx`, `layout.ts`, `layout.js`, `layout.jsx` (Next.js App Router)
249+
- `loading.tsx`, `loading.ts`, `loading.js`, `loading.jsx` (Next.js App Router)
250+
- `error.tsx`, `error.ts`, `error.js`, `error.jsx` (Next.js App Router)
251+
- `not-found.tsx`, `not-found.ts`, `not-found.js`, `not-found.jsx` (Next.js App Router)
252+
- `route.ts`, `route.tsx`, `route.js`, `route.jsx` (Next.js API routes)
253+
- `middleware.ts`, `middleware.js` (Next.js middleware)
254+
- `manifest.ts`, `manifest.js` (PWA manifests)
255+
- `sitemap.ts`, `sitemap.js` (SEO files)
256+
- `robots.ts`, `robots.js` (SEO files)
257+
216258
**Search commands to use:**
217259

218260
```bash
@@ -236,17 +278,20 @@ grep -r "import(" . --exclude-dir=node_modules --exclude-dir=.git | grep "filena
236278
- Verify that the file isn't used in build scripts or deployment configurations
237279
- Ensure the file isn't referenced in documentation or README files
238280
- Double-check that the file isn't used in test files or test configurations
281+
- **NEVER delete files in protected directories or with protected names**
239282

240283
**Checklist for unused file cleanup:**
241284

242285
- [ ] File name has been identified and understood
286+
- [ ] **VERIFIED file is NOT a protected configuration, entry point, generated, or framework file**
243287
- [ ] Searched for exact file name references (without extension)
244288
- [ ] Searched for full relative path references
245289
- [ ] Searched for import statements referencing this file
246290
- [ ] Searched for dynamic imports or require statements
247291
- [ ] Checked configuration files for references
248292
- [ ] Verified file is not used in build/deployment scripts
249293
- [ ] Confirmed file is not referenced in documentation
294+
- [ ] **Double-checked that file is not in a protected directory or has a protected name**
250295
- [ ] File has been safely deleted (if unused)
251296

252297
## Complete Example: Before and After

0 commit comments

Comments
 (0)