💂‍♂️ fixed lint and prittier

This commit is contained in:
RJ
2025-11-14 15:33:00 +02:00
parent 5e9093cf9c
commit 820a2b88d5
43 changed files with 5717 additions and 423 deletions

View File

@@ -15,6 +15,7 @@ Reference this skill when writing or reviewing code to ensure consistency with p
### Files and Directories
**Use kebab-case for all file names:**
```
✅ user-profile.tsx
✅ blog-post-card.tsx
@@ -26,12 +27,14 @@ Reference this skill when writing or reviewing code to ensure consistency with p
```
**Why kebab-case?**
- Cross-platform compatibility (Windows vs Unix)
- URL-friendly (file names often map to routes)
- Easier to parse and read
- Industry standard for Next.js projects
**Special Next.js Files:**
```
page.tsx # Route pages
layout.tsx # Layout components
@@ -44,6 +47,7 @@ route.ts # API route handlers
### Component Names (Inside Files)
**Use PascalCase for component names:**
```typescript
// File: user-profile.tsx
export function UserProfile() {
@@ -59,6 +63,7 @@ export default function BlogPostCard() {
### Variables, Functions, Props
**Use camelCase:**
```typescript
// Variables
const userSettings = {}
@@ -83,10 +88,11 @@ function useMarkdown() {}
### Constants
**Use SCREAMING_SNAKE_CASE:**
```typescript
const API_BASE_URL = "https://api.example.com"
const API_BASE_URL = 'https://api.example.com'
const MAX_RETRIES = 3
const DEFAULT_LOCALE = "ro-RO"
const DEFAULT_LOCALE = 'ro-RO'
```
---
@@ -133,10 +139,7 @@ export async function POST(request: NextRequest) {
const parsed = bodySchema.safeParse(json)
if (!parsed.success) {
return NextResponse.json(
{ error: 'Validation failed', details: parsed.error },
{ status: 400 }
)
return NextResponse.json({ error: 'Validation failed', details: parsed.error }, { status: 400 })
}
// parsed.data is fully typed
@@ -146,6 +149,7 @@ export async function POST(request: NextRequest) {
```
**Key Points:**
- Use `safeParse()` instead of `parse()` to avoid try/catch
- Return structured error responses
- Use appropriate HTTP status codes
@@ -154,6 +158,7 @@ export async function POST(request: NextRequest) {
### Error Handling
**Return meaningful status codes:**
```typescript
200 // Success
201 // Created
@@ -165,12 +170,13 @@ export async function POST(request: NextRequest) {
```
**Structured error responses:**
```typescript
return NextResponse.json(
{
error: 'Resource not found',
code: 'NOT_FOUND',
timestamp: new Date().toISOString()
timestamp: new Date().toISOString(),
},
{ status: 404 }
)
@@ -277,12 +283,12 @@ export function ThemeToggle() {
```javascript
// tailwind.config.js
module.exports = {
darkMode: 'class', // Required for next-themes
darkMode: 'class', // Required for next-themes
theme: {
extend: {
colors: {
'dark-primary': '#18181b',
'accent': {
accent: {
DEFAULT: '#164e63',
hover: '#155e75',
},
@@ -380,6 +386,7 @@ export function Card({ children, className = "" }) {
```
**Standard breakpoints:**
```
sm: 640px // Small tablets
md: 768px // Tablets
@@ -459,18 +466,21 @@ content/ # Content files (outside app/)
### lib/ Organization
**Modules in lib/:**
- Substantial business logic (markdown.ts, seo.ts)
- API clients and data fetching
- Database connections
- Authentication logic
**Utils in lib/utils.ts:**
- Pure helper functions
- Formatters (formatDate, formatCurrency)
- Validators (isEmail, isValidUrl)
- String manipulations
**Types in lib/types/:**
- Shared TypeScript interfaces
- API response types
- Domain models
@@ -479,6 +489,7 @@ content/ # Content files (outside app/)
### Component Organization
**By domain/feature:**
```
components/
├── blog/ # Blog-specific
@@ -495,6 +506,7 @@ components/
```
**Not by type:**
```
❌ Don't organize like this:
components/
@@ -507,6 +519,7 @@ components/
### Public Assets
**Organize by feature:**
```
public/
├── blog/
@@ -519,6 +532,7 @@ public/
```
**Naming conventions:**
- Use descriptive names: `hero-background.jpg` not `img1.jpg`
- Use kebab-case: `user-avatar.png`
- Include dimensions for images: `logo-512x512.png`
@@ -530,9 +544,10 @@ public/
### Type Safety
**Avoid `any`:**
```typescript
// ❌ Bad
function processData(data: any) { }
function processData(data: any) {}
// ✅ Good
function processData(data: unknown) {
@@ -546,7 +561,7 @@ interface PostData {
title: string
content: string
}
function processData(data: PostData) { }
function processData(data: PostData) {}
```
### Infer Types from Zod
@@ -665,6 +680,7 @@ export function InteractiveCard({ title }) {
```
**When to use 'use client':**
- Using React hooks (useState, useEffect, etc.)
- Using event handlers (onClick, onChange, etc.)
- Using browser APIs (window, localStorage, etc.)
@@ -743,7 +759,7 @@ export async function generateStaticParams() {
```typescript
// In frontmatter
date: "2025-01-15"
date: '2025-01-15'
// For display
formatDate(post.frontmatter.date) // "15 ianuarie 2025" (Romanian)