JavaScript
Guida di stile JavaScript completa per progetti PANDEV, ottimizzata per React, Vue, Angular e Node.js.
π― Overview
JavaScript Γ¨ il linguaggio principale per lo sviluppo frontend e sempre piΓΉ utilizzato per backend nei progetti PANDEV. Questa guida copre:
Frontend: React, Vue, Angular
Backend: Node.js, Express
Tools: ESLint, Prettier, Babel
Modern JS: ES6+, async/await, modules
π Standard Adottati
ESLint Standard
Utilizziamo ESLint Standard come base per il linting:
{
"extends": ["standard"],
"env": {
"browser": true,
"node": true,
"es2022": true
}
}Prettier per Formatting
Prettier per la formattazione automatica del codice:
π οΈ Setup Rapido
1. Installazione Dependencies
2. File di Configurazione
Crea .eslintrc.js:
Crea .prettierrc:
3. Scripts Package.json
π¨ Framework Specifici
React Projects
Configurazione specifica per React:
Vue Projects
Configurazione per Vue:
Angular Projects
Angular usa ESLint dalla v12+:
Node.js Projects
Configurazione per backend Node.js:
π Principi Base
1. Modern JavaScript (ES6+)
Usa
consteletinvece divarPreferisci arrow functions per callback
Usa template literals per string interpolation
Destructuring per oggetti e array
Async/await invece di Promise chains
2. Naming Conventions
camelCase: variabili, funzioni, metodi
PascalCase: classi, costruttori, componenti
UPPER_SNAKE_CASE: costanti
kebab-case: file names, CSS classes
3. Code Organization
Un componente/classe per file
Imports ordinati (librerie, locali)
Export espliciti
Separazione logica con commenti
π§ Tools Integration
VS Code Setup
Installa estensioni consigliate:
ESLint (Microsoft)
Prettier (Prettier)
Auto Rename Tag (Jun Han)
Bracket Pair Colorizer (CoenraadS)
Configurazione workspace (.vscode/settings.json):
Pre-commit Hooks
Setup con Husky + lint-staged:
Package.json:
π QualitΓ del Codice
Metrics da Monitorare
ESLint errors: 0 errori in production
Code coverage: > 80%
Cyclomatic complexity: < 10 per funzione
Function length: < 20 linee
File size: < 300 linee
Code Review Checklist
π Performance
Best Practices
Evita re-renders inutili (React.memo, useMemo)
Lazy loading per componenti pesanti
Tree shaking per bundle size
Code splitting per route
Debounce per input frequenti
Bundle Analysis
π Risorse
Documentazione Ufficiale
Framework Guides
Per configurazioni dettagliate e regole specifiche, consulta le sezioni dedicate:
Last updated
Was this helpful?