AGENTS.md: Import Extensions

This commit is contained in:
Alex Gleason committed 2025-09-02 02:07:03 -05:00
1 parent 9741f440eb
commit a55b3418f4
1 file changed
+28
+28
View File
@@ -812,6 +812,34 @@ The router includes automatic scroll-to-top functionality and a 404 NotFound pag
- Comprehensive provider setup with NostrLoginProvider, QueryClientProvider, and custom AppProvider
- **Never use the `any` type**: Always use proper TypeScript types for type safety
### Import Extensions
This project uses ES modules with Node.js-style module resolution (`"type": "module"` and `"moduleResolution": "nodenext"`). **All imports MUST include explicit file extensions**, and specifically **`.js`/`.jsx` extensions must be used** even when importing TypeScript files.
This is because TypeScript compiles to JavaScript, and the runtime expects the actual file extensions that will exist after compilation.
#### Examples
**✅ Correct imports with .js/.jsx extensions:**
```typescript
// Import TypeScript files with .js extension
import { useAuthor } from '@/hooks/useAuthor.js';
import { Button } from '@/components/ui/button.jsx';
import { LoginArea } from "@/components/auth/LoginArea.jsx";
import AppRouter from "./AppRouter.jsx";
import { cn } from '@/lib/utils.js';
```
**❌ Wrong imports (wrong extensions or no extension):**
```typescript
// These will cause build/runtime errors
import { useAuthor } from '@/hooks/useAuthor';
import { Button } from '@/components/ui/button.tsx';
import { LoginArea } from "@/components/auth/LoginArea";
import AppRouter from "./AppRouter";
import { cn } from '@/lib/utils.ts';
```
## Loading States
**Use skeleton loading** for structured content (feeds, profiles, forms). **Use spinners** only for buttons or short operations.