Visual Studio Code (VS Code) is the most widely used code editor for JavaScript and MERN development. Out of the box it already provides syntax highlighting, IntelliSense, and Git integration. But with the right extensions and settings configured, VS Code becomes a MERN-specific development environment: it catches errors before you run your code, formats your files automatically on save, gives you inline documentation for every npm package, and lets you test API endpoints without leaving the editor. In this lesson you will set up VS Code exactly as experienced MERN developers use it.
Essential VS Code Extensions for MERN
| Extension | Publisher | What It Does |
|---|---|---|
| ESLint | Microsoft | Highlights JavaScript and JSX errors and style violations in real time |
| Prettier โ Code formatter | Prettier | Auto-formats JS, JSX, CSS, JSON on save โ consistent style across the team |
| ES7+ React/Redux/React-Native snippets | dsznajder | Shortcuts like rafce โ full React arrow function component |
| MongoDB for VS Code | MongoDB | Browse Atlas clusters and run queries directly inside the editor |
| Thunder Client | Ranga Vadhineni | Lightweight REST client built into VS Code โ test API endpoints without Postman |
| GitLens | GitKraken | Inline Git blame, history, and branch visualisation |
| Auto Rename Tag | Jun Han | Automatically renames paired JSX/HTML tags when you edit one |
| Path Intellisense | Christian Kohler | Autocompletes file paths in import statements |
| DotENV | mikestead | Syntax highlighting for .env files |
| Bracket Pair Colorizer | Built-in (VS Code 1.60+) | Colours matching brackets โ enable with editor.bracketPairColorization.enabled: true |
Ctrl+Shift+X / Cmd+Shift+X) or from the command line using code --install-extension publisher.extension-name. If you are setting up a new machine, you can export and import your full extension list using the VS Code Settings Sync feature (sign in with GitHub or Microsoft)..vscode/settings.json file in the root of your project to share editor settings with your team. This file is committed to Git and overrides individual user settings for that workspace. It ensures everyone on the team uses the same formatter, tab size, and ESLint configuration โ preventing annoying whitespace-only diffs in pull requests.eslint-config-prettier to disable all ESLint rules that conflict with Prettier.Recommended VS Code Settings
// .vscode/settings.json โ commit this file to Git for team consistency
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 2,
"editor.wordWrap": "on",
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true,
"editor.suggestSelection": "first",
"editor.inlineSuggest.enabled": true,
"eslint.validate": ["javascript", "javascriptreact"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"files.autoSave": "onFocusChange",
"files.exclude": {
"node_modules": true,
".git": true
},
"emmet.includeLanguages": {
"javascript": "javascriptreact"
},
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.fontSize": 13
}
ESLint Configuration for MERN
# Install ESLint in your server project
cd server
npm install -D eslint
# Initialise ESLint interactively
npx eslint --init
# Answer:
# How would you like to use ESLint? โ To check syntax and find problems
# What type of modules? โ CommonJS (require/exports)
# Which framework? โ None
# Does your project use TypeScript? โ No
# Where does your code run? โ Node
# โ This creates .eslintrc.json in your project root
// server/.eslintrc.json โ recommended MERN server config
{
"env": {
"node": true,
"es2021": true
},
"extends": ["eslint:recommended"],
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
"no-unused-vars": "warn",
"no-console": "off",
"no-undef": "error",
"semi": ["warn", "always"],
"eqeqeq": ["error", "always"]
}
}
Prettier Configuration
// .prettierrc โ place in project root, applies to both client and server
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 100,
"endOfLine": "lf"
}
Useful VS Code Keyboard Shortcuts for MERN
| Action | macOS | Windows / Linux |
|---|---|---|
| Command Palette | Cmd+Shift+P |
Ctrl+Shift+P |
| Quick file open | Cmd+P |
Ctrl+P |
| Toggle terminal | Ctrl+` |
Ctrl+` |
| Format document | Shift+Alt+F |
Shift+Alt+F |
| Rename symbol | F2 |
F2 |
| Go to definition | F12 |
F12 |
| Multi-cursor | Opt+Click |
Alt+Click |
| Duplicate line | Shift+Alt+โ |
Shift+Alt+โ |
| Move line up/down | Alt+โ/โ |
Alt+โ/โ |
| Toggle comment | Cmd+/ |
Ctrl+/ |
Common Mistakes
Mistake 1 โ Not enabling format on save
โ Wrong โ manually running Prettier only occasionally leaves inconsistent formatting across files:
// settings.json โ format on save is off (default)
{ "editor.formatOnSave": false }
โ Correct โ set formatOnSave to true so every file is automatically formatted the moment you save it:
{ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" }
Mistake 2 โ Installing extensions globally instead of per workspace
โ Wrong โ every developer manually installs extensions and uses different versions, leading to inconsistent behaviour across the team.
โ
Correct โ create a .vscode/extensions.json file listing recommended extensions. VS Code will prompt any developer who opens the project to install them:
// .vscode/extensions.json
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"dsznajder.es7-react-js-snippets",
"mongodb.mongodb-vscode",
"rangav.vscode-thunder-client"
]
}
Mistake 3 โ Ignoring ESLint warnings
โ Wrong โ dismissing yellow underlines and letting warnings accumulate until the codebase has hundreds of ignored issues:
const token = generateToken(); // ESLint: 'token' is assigned a value but never used
// Developer ignores warning โ potential bug hiding in plain sight
โ Correct โ treat ESLint warnings as TODO items. A warning usually means either the code has a bug, or an unused variable should be removed to keep the codebase clean.
Quick Reference
| File | Location | Purpose |
|---|---|---|
.vscode/settings.json |
Project root | Shared editor settings for the team |
.vscode/extensions.json |
Project root | Recommended extensions list |
.eslintrc.json |
server/ and client/ | ESLint rules per sub-project |
.prettierrc |
Project root | Prettier formatting rules |
.prettierignore |
Project root | Files Prettier should not format (e.g. dist/) |