VSCode Oppsett
Denne guiden hjelper deg med å sette opp Visual Studio Code optimalt for TypeScript og React-utvikling i echo Webkom. Du lærer om essensielle extensions, innstillinger, og arbeidsflyt.
1. Installer VSCode
Section titled “1. Installer VSCode”Last ned og installer Visual Studio Code fra code.visualstudio.com.
Installer via package managers (valgfritt)
Section titled “Installer via package managers (valgfritt)”# macOS med Homebrewbrew install --cask visual-studio-code
2. Essensielle Extensions
Section titled “2. Essensielle Extensions”TypeScript og React utvikling
Section titled “TypeScript og React utvikling”# Installer via kommandolinje (valgfritt)code --install-extension ms-vscode.vscode-typescript-nextcode --install-extension bradlc.vscode-tailwindcsscode --install-extension ms-vscode.vscode-jsoncode --install-extension ms-vscode.vscode-eslintcode --install-extension esbenp.prettier-vscode
Obligatoriske extensions:
-
TypeScript Importer (
pmneo.tsimporter
)- Automatisk import av TypeScript moduler
- Intelligent code completion
-
Tailwind CSS IntelliSense (
bradlc.vscode-tailwindcss
)- Autocomplete for Tailwind klasser
- Hover-forhåndsvisning av CSS
-
ESLint (
ms-vscode.eslint
)- Lint og feildeteksjon i koden
- Automatisk fixing av vanlige problemer
-
Prettier (
esbenp.prettier-vscode
)- Automatisk kodeformatering
- Konsistent kodestil
React-spesifikke extensions
Section titled “React-spesifikke extensions”code --install-extension ms-vscode.vscode-emmet
Git & Collaboration
Section titled “Git & Collaboration”code --install-extension eamodio.gitlenscode --install-extension github.vscode-pull-request-github
-
GitLens (
eamodio.gitlens
)- Forbedret Git-integrasjon
- Blame annotations og commit historikk
-
GitHub Pull Requests (
github.vscode-pull-request-github
)- Håndter PR-er direkte i VSCode
- Code review i editoren
3. VSCode Innstillinger
Section titled “3. VSCode Innstillinger”Opprett eller oppdater settings.json
filen din:
{ // Formatering og linting "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit", "source.organizeImports": "explicit" },
// Prettier som standard formatter "editor.defaultFormatter": "esbenp.prettier-vscode",
// TypeScript-spesifikke innstillinger "typescript.preferences.importModuleSpecifier": "relative", "typescript.suggest.autoImports": true, "typescript.updateImportsOnFileMove.enabled": "always",
// React-spesifikke innstillinger "emmet.includeLanguages": { "javascript": "javascriptreact", "typescript": "typescriptreact" },
// Tailwind CSS "tailwindCSS.experimental.classRegex": [ ["cn\\(([^)]*)\\)", "'([^']*)'"], ["clsx\\(([^)]*)\\)", "'([^']*)'"] ],
// Søk og filer "search.exclude": { "**/node_modules": true, "**/dist": true, "**/.next": true, "**/build": true },
// Editor forbedringer "editor.minimap.enabled": false, "editor.linkedEditing": true, "editor.bracketPairColorization.enabled": true, "editor.guides.bracketPairs": true, "editor.inlineSuggest.enabled": true}
4. Nyttige Snippets
Section titled “4. Nyttige Snippets”Opprett egne snippets for echo Webkom utvikling. Gå til File → Preferences → Configure User Snippets:
TypeScript React Snippets (typescriptreact.json
)
Section titled “TypeScript React Snippets (typescriptreact.json)”{ "echo React Component": { "prefix": "erc", "body": [ "type ${1:ComponentName}Props = {", " $2", "}", "", "export const ${1:ComponentName} = ({ $3 }: ${1:ComponentName}Props) => {", " return (", " <div className=\"$4\">", " $0", " </div>", " );", "};" ], "description": "echo React Component with TypeScript" },
"echo Server Action": { "prefix": "esa", "body": [ "\"use server\";", "", "import { auth } from \"@/auth/server\";", "import { db } from \"@echo-webkom/db\";", "", "export async function ${1:actionName}() {", " const session = await auth();", " ", " if (!session?.user) {", " throw new Error(\"Unauthorized\");", " }", "", " $0", "}" ], "description": "echo Server Action template" }}
5. Keyboard Shortcuts
Section titled “5. Keyboard Shortcuts”Viktige shortcuts for echo Webkom utvikling:
Shortcut | Funksjon |
---|---|
Cmd/Ctrl + Shift + P | Command Palette |
Cmd/Ctrl + P | Quick Open File |
Cmd/Ctrl + Shift + F | Global søk |
Cmd/Ctrl + D | Velg neste match |
Alt + Shift + F | Format Document |
Cmd/Ctrl + Shift + O | Go to Symbol |
F12 | Go to Definition |
Shift + F12 | Find All References |
Cmd/Ctrl + Shift + L | Select all matches |
Cmd/Ctrl + / | Toggle comment |
6. Produktivitetstips
Section titled “6. Produktivitetstips”IntelliSense og Autocomplete
Section titled “IntelliSense og Autocomplete”- Bruk
Ctrl + Space
for å utløse suggestions Tab
for å akseptere suggestionsEsc
for å lukke suggestion-menyen
Quick Actions
Section titled “Quick Actions”Cmd/Ctrl + .
for Quick Fix actions- Automatisk import av manglende moduler
- Refactoring shortcuts
Multi-cursor Editing
Section titled “Multi-cursor Editing”Alt + Click
for å plassere flere cursorsCmd/Ctrl + Shift + L
for å velge alle forekomsterCmd/Ctrl + D
for å velge neste forekomst
File Navigation
Section titled “File Navigation”Cmd/Ctrl + P
→ skriv filnavn for rask navigering@
symbol for å hoppe til symboler i fil#
symbol for å søke i workspace
7. Troubleshooting
Section titled “7. Troubleshooting”TypeScript funker ikke?
Section titled “TypeScript funker ikke?”- Sjekk at TypeScript extension er installert og aktivert
- Restart TypeScript Server:
Cmd/Ctrl + Shift + P
→ “TypeScript: Restart TS Server” - Kontroller at
tsconfig.json
er konfigurert riktig
ESLint issues
Section titled “ESLint issues”- Sjekk at
eslint.config.js
finnes i prosjektet - Restart ESLint Server:
Cmd/Ctrl + Shift + P
→ “ESLint: Restart ESLint Server” - Kontroller at ESLint extension kan finne config-filen
Prettier ikke formatting
Section titled “Prettier ikke formatting”- Kontroller at Prettier er satt som default formatter
- Sjekk
prettier.config.cjs
i prosjektrotmappen - Enable “Format on Save” i settings
8. echo Webkom Workflow
Section titled “8. echo Webkom Workflow”Daglig arbeidsflyt
Section titled “Daglig arbeidsflyt”- Åpne terminal i VSCode (
Ctrl + ``
“) - Pull latest changes:
git pull origin main
- Start development server:
pnpm dev
- Bruk integrated terminal for alle Git-operasjoner
Code Review
Section titled “Code Review”- Bruk GitHub Pull Requests extension
- Review endringer direkte i VSCode
- Kommenter på linjer og submit reviews