Thank you for your interest in contributing to the Prettier VS Code extension! Feel free to open issues or PRs.
- Node.js (see
.nvmrcfor version) - Visual Studio Code
-
Clone the repository:
git clone https://github.com/prettier/prettier-vscode.git cd prettier-vscode -
Install dependencies:
npm install
-
Build the extension:
npm run compile
npm install # Install dependencies
npm run compile # Build for development (esbuild + type checking)
npm run compile:test # Compile tests only
npm run watch # Build and watch for changes
npm run lint # Run ESLint
npm run prettier # Format code with Prettier
npm test # Run tests- Open this repository in VS Code
- Run
npm run compileto build - Press
F5or go to Debug sidebar → "Run Extension" - A new VS Code window will open with the extension loaded
Tests run inside a VS Code instance and use the test-fixtures/ workspace.
Desktop Tests (Via VS Code):
- Open this repository in VS Code
- Go to Debug sidebar → "Launch Tests"
Desktop Tests (Via CLI):
npm testNote: No VS Code instance can be running when using the CLI, or tests won't start.
Web Extension Tests:
npm run test:webThis runs the extension in a headless Chromium browser to verify the web extension works correctly.
- Code is formatted with Prettier (run
npm run prettierbefore committing) - Linting is enforced with ESLint (run
npm run lintto check) - Pre-commit hooks automatically format and lint staged files
The extension has two entry points:
- Desktop:
src/extension.ts→dist/extension.js - Browser:
src/extension.ts→dist/web-extension.js
Key components:
PrettierEditService.ts- Handles document formattingModuleResolver.ts- Resolves Prettier installations (local, global, or bundled)
- Fork the repository and create a branch for your changes
- Make your changes and ensure tests pass (
npm test) - Run
npm run lintandnpm run prettierto ensure code style compliance - Submit a pull request with a clear description of your changes
For bug fixes, please include a test case that demonstrates the fix when possible.